<!DOCTYPE html><html class="hide-aside" lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>RIME配置指南 | 西山晴雪的知识笔记</title><meta name="keywords" content="软件安装与使用,Linux"><meta name="author" content="西山晴雪"><meta name="copyright" content="西山晴雪"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="RIME配置指南">
<meta property="og:type" content="article">
<meta property="og:title" content="RIME配置指南">
<meta property="og:url" content="http://xishansnow.github.io/posts/6811304.html">
<meta property="og:site_name" content="西山晴雪的知识笔记">
<meta property="og:description" content="RIME配置指南">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="http://xishansnow.github.io/img/book_01.png">
<meta property="article:published_time" content="2022-04-02T08:30:00.000Z">
<meta property="article:modified_time" content="2022-12-28T08:47:47.456Z">
<meta property="article:author" content="西山晴雪">
<meta property="article:tag" content="软件安装与使用">
<meta property="article:tag" content="Linux">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="http://xishansnow.github.io/img/book_01.png"><link rel="shortcut icon" href="/img/favi.jpg"><link rel="canonical" href="http://xishansnow.github.io/posts/6811304"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: {"appId":"12DC1Q07CH","apiKey":"7e4ac2a644127298a8a2e8170335afdb","indexName":"xishansnowblog","hits":{"per_page":6},"languages":{"input_placeholder":"搜索文章","hits_empty":"找不到您查询的内容：${query}","hits_stats":"找到 ${hits} 条结果，用时 ${time} 毫秒"}},
  localSearch: undefined,
  translate: {"defaultEncoding":2,"translateDelay":0,"msgToTraditionalChinese":"繁","msgToSimplifiedChinese":"簡"},
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/flickr-justified-gallery/dist/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'RIME配置指南',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2022-12-28 16:47:47'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="/css/custom.css"><script defer src="https://cdn.jsdelivr.net/npm/katex@0.16.3/dist/contrib/auto-render.min.js" integrity="sha384-+VBxd3r6XgURycqtZ117nYw44OOcIax56Z4dCRWbxyPt0Koah1uHoK0o4+/RRE05" crossorigin="anonymous" onload="renderMathInElement(document.body);"></script><meta name="generator" content="Hexo 5.4.2"></head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="/img/favi.jpg" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">306</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">390</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">89</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-atom"></i><span> 预测</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E5%B9%BF%E4%B9%89%E7%BA%BF%E6%80%A7%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fas fa-atom"></i><span> 广义线性模型</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E9%9D%9E%E5%8F%82%E6%95%B0%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fas fa-cogs"></i><span> 传统非参数模型</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E9%AB%98%E6%96%AF%E8%BF%87%E7%A8%8B/"><i class="fa-fw fas fa-school"></i><span> 高斯过程</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"><i class="fa-fw fas fa-layer-group"></i><span> 神经网络</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E6%A8%A1%E5%9E%8B%E9%80%89%E6%8B%A9%E4%B8%8E%E5%B9%B3%E5%9D%87/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 模型选择与平均</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E5%B0%8F%E6%A0%B7%E6%9C%AC%E5%AD%A6%E4%B9%A0/"><i class="fa-fw fa-solid fa-globe"></i><span> 小样本学习</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-file-export"></i><span> 生成</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E4%BC%A0%E7%BB%9F%E6%A6%82%E7%8E%87%E5%9B%BE%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 传统概率图模型</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E7%8E%BB%E5%B0%94%E5%85%B9%E6%9B%BC%E6%9C%BA/"><i class="fa-fw fa-solid fa-deezer"></i><span> 玻耳兹曼机</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E5%8F%98%E5%88%86%E8%87%AA%E7%BC%96%E7%A0%81%E5%99%A8/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 变分自编码器</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E8%87%AA%E5%9B%9E%E5%BD%92%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-codepen"></i><span> 自回归模型</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E5%BD%92%E4%B8%80%E5%8C%96%E6%B5%81/"><i class="fa-fw fa-solid fa-cube"></i><span> 归一化流</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E6%89%A9%E6%95%A3%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-solid fa-ghost"></i><span> 扩散模型</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E8%83%BD%E9%87%8F%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-solid fa-gas-pump"></i><span> 能量模型</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E7%94%9F%E6%88%90%E5%BC%8F%E5%AF%B9%E6%8A%97%E7%BD%91%E7%BB%9C/"><i class="fa-fw fa-solid fa-globe"></i><span> 生成式对抗网络</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-magnet"></i><span> 挖掘</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E9%9A%90%E5%9B%A0%E5%AD%90%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 隐因子模型</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E7%8A%B6%E6%80%81%E7%A9%BA%E9%97%B4%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-deezer"></i><span> 状态空间模型</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E6%A6%82%E7%8E%87%E5%9B%BE%E5%AD%A6%E4%B9%A0/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 概率图学习</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E9%9D%9E%E5%8F%82%E6%95%B0%E8%B4%9D%E5%8F%B6%E6%96%AF%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-codepen"></i><span> 非参数贝叶斯模型</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E8%A1%A8%E7%A4%BA%E5%AD%A6%E4%B9%A0/"><i class="fa-fw fa-solid fa-cube"></i><span> 表示学习</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E5%8F%AF%E8%A7%A3%E9%87%8A%E6%80%A7/"><i class="fa-fw fa-solid fa-ghost"></i><span> 可解释性</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E9%99%8D%E7%BB%B4/"><i class="fa-fw fa-solid fa-gas-pump"></i><span> 降维</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E8%81%9A%E7%B1%BB/"><i class="fa-fw fa-solid fa-cogs"></i><span> 聚类</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-compass"></i><span> 贝叶斯</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E6%A6%82%E7%8E%87%E5%9B%BE%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-codepen"></i><span> 概率图模型</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E8%92%99%E7%89%B9%E5%8D%A1%E6%B4%9B%E6%8E%A8%E6%96%AD/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 蒙特卡罗推断</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E5%8F%98%E5%88%86%E6%8E%A8%E6%96%AD/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 变分推断</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E8%BF%91%E4%BC%BC%E8%B4%9D%E5%8F%B6%E6%96%AF%E8%AE%A1%E7%AE%97/"><i class="fa-fw fa-solid fa-cube"></i><span> 近似贝叶斯计算</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E8%B4%9D%E5%8F%B6%E6%96%AF%E6%A8%A1%E5%9E%8B%E6%AF%94%E8%BE%83%E4%B8%8E%E9%80%89%E6%8B%A9/"><i class="fa-fw fa-solid fa-ghost"></i><span> 模型比较与选择</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E8%B4%9D%E5%8F%B6%E6%96%AF%E4%BC%98%E5%8C%96/"><i class="fa-fw fa-solid fa-gas-pump"></i><span> 贝叶斯优化</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-ghost"></i><span> 不确定性DL</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/BayesNN/%E6%A6%82%E8%A7%88"><i class="fa-fw fa-solid fa-cube"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E5%8D%95%E4%B8%80%E7%A1%AE%E5%AE%9A%E6%80%A7%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 单一确定性神经网络</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"><i class="fa-fw fa-brands fa-deezer"></i><span> 贝叶斯神经网络</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E6%B7%B1%E5%BA%A6%E9%9B%86%E6%88%90/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 深度集成</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E6%95%B0%E6%8D%AE%E5%A2%9E%E5%BC%BA/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 数据增强</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E5%AF%B9%E6%AF%94%E4%B8%8E%E8%AF%84%E6%B5%8B/"><i class="fa-fw fa-brands fa-deezer"></i><span> 对比与评测</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-map"></i><span> 空间统计</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/GeoAI/%E7%BB%BC%E8%BF%B0%E7%B1%BB/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%82%B9%E5%8F%82%E8%80%83%E6%95%B0%E6%8D%AE/"><i class="fa-fw fa-solid fa-map"></i><span> 点参考数据</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E9%9D%A2%E5%85%83%E6%95%B0%E6%8D%AE/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 面元数据</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%82%B9%E6%A8%A1%E5%BC%8F%E6%95%B0%E6%8D%AE/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 点模式数据</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%A9%BA%E9%97%B4%E8%B4%9D%E5%8F%B6%E6%96%AF%E6%96%B9%E6%B3%95/"><i class="fa-fw fa-solid fa-cube"></i><span> 空间贝叶斯方法</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%A9%BA%E9%97%B4%E5%8F%98%E7%B3%BB%E6%95%B0%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-solid fa-ghost"></i><span> 空间变系数模型</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%A9%BA%E9%97%B4%E7%BB%9F%E8%AE%A1%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/"><i class="fa-fw fa-brands fa-deezer"></i><span> 空间统计深度学习</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E6%97%B6%E7%A9%BA%E7%BB%9F%E8%AE%A1%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fas fa-atlas"></i><span> 时空统计模型</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B8%93%E9%A2%98/"><i class="fa-fw fa fa-anchor"></i><span> 大数据专题</span></a></li><li><a class="site-page child" href="/categories/GeoAI/GeoAI/"><i class="fa-fw fa-brands fa-codepen"></i><span> GeoAI</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-database"></i><span> 基础</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E9%AB%98%E7%AD%89%E6%95%B0%E5%AD%A6/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 高等数学</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E6%A6%82%E7%8E%87%E4%B8%8E%E7%BB%9F%E8%AE%A1/"><i class="fa-fw fa-brands fa-deezer"></i><span> 概率与统计</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E7%BA%BF%E4%BB%A3%E4%B8%8E%E7%9F%A9%E9%98%B5%E8%AE%BA/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 线代与矩阵论</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E6%9C%80%E4%BC%98%E5%8C%96%E7%90%86%E8%AE%BA/"><i class="fa-fw fa-brands fa-codepen"></i><span> 最优化理论</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E4%BF%A1%E6%81%AF%E8%AE%BA/"><i class="fa-fw fa-solid fa-cube"></i><span> 信息论</span></a></li><li><a class="site-page child" href="/categories/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E6%A8%A1%E5%9E%8B/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-ghost"></i><span> 机器学习</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E7%9F%A5%E8%AF%86%E5%9B%BE%E8%B0%B1/"><i class="fa-fw fa-solid fa-globe"></i><span> 知识图谱</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E8%87%AA%E7%84%B6%E8%AF%AD%E8%A8%80%E5%A4%84%E7%90%86/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 自然语言处理</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E6%A6%82%E7%8E%87%E7%BC%96%E7%A8%8B/"><i class="fa-fw fas  fa-atlas"></i><span> 概率编程</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-book-open"></i><span> 书籍</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="https://xishansnow.github.io/BayesianAnalysiswithPython2nd/index.html"><i class="fa-fw fa-solid  fa-landmark-dome"></i><span> 《Bayesian Analysis with Python》</span></a></li><li><a class="site-page child" href="https://xishansnow.github.io/BayesianModelingandComputationInPython/index.html"><i class="fa-fw fa-solid  fa-graduation-cap"></i><span> 《Bayesian Modeling and Computation in Python》</span></a></li><li><a class="site-page child" href="https://xishansnow.github.io/ElementsOfStatisticalLearning/index.html"><i class="fa-fw fa-solid  fa-book-atlas"></i><span> 《统计学习精要（ESL）》</span></a></li><li><a class="site-page child" href="https://xishansnow.github.io/spatialSTAT_CN/index.html"><i class="fa-fw fa-solid  fa-layer-group"></i><span> 《空间统计学》</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://otexts.com/fppcn/index.html"><i class="fa-fw fa-solid  fa-cloud-sun-rain"></i><span> 《预测：方法与实践》</span></a></li><li><a class="site-page child" href="https://xishansnow.github.io/MLAPP/index.html"><i class="fa-fw fa-solid  fa-robot"></i><span> 《机器学习的概率视角（MLAPP）》</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-compass"></i><span> 索引</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fa-solid fa-timeline"></i><span> 时间索引</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签索引</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类索引</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-link"></i><span> 其他</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/link/food/"><i class="fa-fw fas fa-utensils"></i><span> 美食博主</span></a></li><li><a class="site-page child" href="/link/photography"><i class="fa-fw fas fa-camera"></i><span> 摄影大神</span></a></li><li><a class="site-page child" href="/link/paper/"><i class="fa-fw fas fa-book-open"></i><span> 学术工具</span></a></li><li><a class="site-page child" href="/gallery/"><i class="fa-fw fas fa-images"></i><span> 摄影作品</span></a></li><li><a class="site-page child" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/img/book_01.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">西山晴雪的知识笔记</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 主页</span></a></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-atom"></i><span> 预测</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E5%B9%BF%E4%B9%89%E7%BA%BF%E6%80%A7%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fas fa-atom"></i><span> 广义线性模型</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E9%9D%9E%E5%8F%82%E6%95%B0%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fas fa-cogs"></i><span> 传统非参数模型</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E9%AB%98%E6%96%AF%E8%BF%87%E7%A8%8B/"><i class="fa-fw fas fa-school"></i><span> 高斯过程</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"><i class="fa-fw fas fa-layer-group"></i><span> 神经网络</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E6%A8%A1%E5%9E%8B%E9%80%89%E6%8B%A9%E4%B8%8E%E5%B9%B3%E5%9D%87/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 模型选择与平均</span></a></li><li><a class="site-page child" href="/categories/%E9%A2%84%E6%B5%8B%E4%BB%BB%E5%8A%A1/%E5%B0%8F%E6%A0%B7%E6%9C%AC%E5%AD%A6%E4%B9%A0/"><i class="fa-fw fa-solid fa-globe"></i><span> 小样本学习</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-file-export"></i><span> 生成</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E4%BC%A0%E7%BB%9F%E6%A6%82%E7%8E%87%E5%9B%BE%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 传统概率图模型</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E7%8E%BB%E5%B0%94%E5%85%B9%E6%9B%BC%E6%9C%BA/"><i class="fa-fw fa-solid fa-deezer"></i><span> 玻耳兹曼机</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E5%8F%98%E5%88%86%E8%87%AA%E7%BC%96%E7%A0%81%E5%99%A8/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 变分自编码器</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E8%87%AA%E5%9B%9E%E5%BD%92%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-codepen"></i><span> 自回归模型</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E5%BD%92%E4%B8%80%E5%8C%96%E6%B5%81/"><i class="fa-fw fa-solid fa-cube"></i><span> 归一化流</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E6%89%A9%E6%95%A3%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-solid fa-ghost"></i><span> 扩散模型</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E8%83%BD%E9%87%8F%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-solid fa-gas-pump"></i><span> 能量模型</span></a></li><li><a class="site-page child" href="/categories/%E7%94%9F%E6%88%90%E4%BB%BB%E5%8A%A1/%E7%94%9F%E6%88%90%E5%BC%8F%E5%AF%B9%E6%8A%97%E7%BD%91%E7%BB%9C/"><i class="fa-fw fa-solid fa-globe"></i><span> 生成式对抗网络</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-magnet"></i><span> 挖掘</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E9%9A%90%E5%9B%A0%E5%AD%90%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 隐因子模型</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E7%8A%B6%E6%80%81%E7%A9%BA%E9%97%B4%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-deezer"></i><span> 状态空间模型</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E6%A6%82%E7%8E%87%E5%9B%BE%E5%AD%A6%E4%B9%A0/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 概率图学习</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E9%9D%9E%E5%8F%82%E6%95%B0%E8%B4%9D%E5%8F%B6%E6%96%AF%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-codepen"></i><span> 非参数贝叶斯模型</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E8%A1%A8%E7%A4%BA%E5%AD%A6%E4%B9%A0/"><i class="fa-fw fa-solid fa-cube"></i><span> 表示学习</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E5%8F%AF%E8%A7%A3%E9%87%8A%E6%80%A7/"><i class="fa-fw fa-solid fa-ghost"></i><span> 可解释性</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E9%99%8D%E7%BB%B4/"><i class="fa-fw fa-solid fa-gas-pump"></i><span> 降维</span></a></li><li><a class="site-page child" href="/categories/%E5%8F%91%E7%8E%B0%E4%BB%BB%E5%8A%A1/%E8%81%9A%E7%B1%BB/"><i class="fa-fw fa-solid fa-cogs"></i><span> 聚类</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-compass"></i><span> 贝叶斯</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E6%A6%82%E7%8E%87%E5%9B%BE%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-brands fa-codepen"></i><span> 概率图模型</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E8%92%99%E7%89%B9%E5%8D%A1%E6%B4%9B%E6%8E%A8%E6%96%AD/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 蒙特卡罗推断</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E5%8F%98%E5%88%86%E6%8E%A8%E6%96%AD/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 变分推断</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E8%BF%91%E4%BC%BC%E8%B4%9D%E5%8F%B6%E6%96%AF%E8%AE%A1%E7%AE%97/"><i class="fa-fw fa-solid fa-cube"></i><span> 近似贝叶斯计算</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E8%B4%9D%E5%8F%B6%E6%96%AF%E6%A8%A1%E5%9E%8B%E6%AF%94%E8%BE%83%E4%B8%8E%E9%80%89%E6%8B%A9/"><i class="fa-fw fa-solid fa-ghost"></i><span> 模型比较与选择</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E8%B4%9D%E5%8F%B6%E6%96%AF%E4%BC%98%E5%8C%96/"><i class="fa-fw fa-solid fa-gas-pump"></i><span> 贝叶斯优化</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-ghost"></i><span> 不确定性DL</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/BayesNN/%E6%A6%82%E8%A7%88"><i class="fa-fw fa-solid fa-cube"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E5%8D%95%E4%B8%80%E7%A1%AE%E5%AE%9A%E6%80%A7%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 单一确定性神经网络</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%A5%9E%E7%BB%8F%E7%BD%91%E7%BB%9C/"><i class="fa-fw fa-brands fa-deezer"></i><span> 贝叶斯神经网络</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E6%B7%B1%E5%BA%A6%E9%9B%86%E6%88%90/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 深度集成</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E6%95%B0%E6%8D%AE%E5%A2%9E%E5%BC%BA/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 数据增强</span></a></li><li><a class="site-page child" href="/categories/BayesNN/%E5%AF%B9%E6%AF%94%E4%B8%8E%E8%AF%84%E6%B5%8B/"><i class="fa-fw fa-brands fa-deezer"></i><span> 对比与评测</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-map"></i><span> 空间统计</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/GeoAI/%E7%BB%BC%E8%BF%B0%E7%B1%BB/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 概览</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%82%B9%E5%8F%82%E8%80%83%E6%95%B0%E6%8D%AE/"><i class="fa-fw fa-solid fa-map"></i><span> 点参考数据</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E9%9D%A2%E5%85%83%E6%95%B0%E6%8D%AE/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 面元数据</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%82%B9%E6%A8%A1%E5%BC%8F%E6%95%B0%E6%8D%AE/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 点模式数据</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%A9%BA%E9%97%B4%E8%B4%9D%E5%8F%B6%E6%96%AF%E6%96%B9%E6%B3%95/"><i class="fa-fw fa-solid fa-cube"></i><span> 空间贝叶斯方法</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%A9%BA%E9%97%B4%E5%8F%98%E7%B3%BB%E6%95%B0%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fa-solid fa-ghost"></i><span> 空间变系数模型</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E7%A9%BA%E9%97%B4%E7%BB%9F%E8%AE%A1%E6%B7%B1%E5%BA%A6%E5%AD%A6%E4%B9%A0/"><i class="fa-fw fa-brands fa-deezer"></i><span> 空间统计深度学习</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E6%97%B6%E7%A9%BA%E7%BB%9F%E8%AE%A1%E6%A8%A1%E5%9E%8B/"><i class="fa-fw fas fa-atlas"></i><span> 时空统计模型</span></a></li><li><a class="site-page child" href="/categories/GeoAI/%E5%A4%A7%E6%95%B0%E6%8D%AE%E4%B8%93%E9%A2%98/"><i class="fa-fw fa fa-anchor"></i><span> 大数据专题</span></a></li><li><a class="site-page child" href="/categories/GeoAI/GeoAI/"><i class="fa-fw fa-brands fa-codepen"></i><span> GeoAI</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-database"></i><span> 基础</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E9%AB%98%E7%AD%89%E6%95%B0%E5%AD%A6/"><i class="fa-fw fa-solid fa-chart-area"></i><span> 高等数学</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E6%A6%82%E7%8E%87%E4%B8%8E%E7%BB%9F%E8%AE%A1/"><i class="fa-fw fa-brands fa-deezer"></i><span> 概率与统计</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E7%BA%BF%E4%BB%A3%E4%B8%8E%E7%9F%A9%E9%98%B5%E8%AE%BA/"><i class="fa-fw fa-brands fa-cloudsmith"></i><span> 线代与矩阵论</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E6%9C%80%E4%BC%98%E5%8C%96%E7%90%86%E8%AE%BA/"><i class="fa-fw fa-brands fa-codepen"></i><span> 最优化理论</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E4%BF%A1%E6%81%AF%E8%AE%BA/"><i class="fa-fw fa-solid fa-cube"></i><span> 信息论</span></a></li><li><a class="site-page child" href="/categories/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0%E6%A8%A1%E5%9E%8B/%E6%A6%82%E8%A7%88/"><i class="fa-fw fa-solid fa-ghost"></i><span> 机器学习</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E7%9F%A5%E8%AF%86%E5%9B%BE%E8%B0%B1/"><i class="fa-fw fa-solid fa-globe"></i><span> 知识图谱</span></a></li><li><a class="site-page child" href="/categories/%E5%9F%BA%E7%A1%80%E7%90%86%E8%AE%BA%E7%9F%A5%E8%AF%86/%E8%87%AA%E7%84%B6%E8%AF%AD%E8%A8%80%E5%A4%84%E7%90%86/"><i class="fa-fw fa-solid fa-hands-holding"></i><span> 自然语言处理</span></a></li><li><a class="site-page child" href="/categories/%E8%B4%9D%E5%8F%B6%E6%96%AF%E7%BB%9F%E8%AE%A1/%E6%A6%82%E7%8E%87%E7%BC%96%E7%A8%8B/"><i class="fa-fw fas  fa-atlas"></i><span> 概率编程</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-book-open"></i><span> 书籍</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="https://xishansnow.github.io/BayesianAnalysiswithPython2nd/index.html"><i class="fa-fw fa-solid  fa-landmark-dome"></i><span> 《Bayesian Analysis with Python》</span></a></li><li><a class="site-page child" href="https://xishansnow.github.io/BayesianModelingandComputationInPython/index.html"><i class="fa-fw fa-solid  fa-graduation-cap"></i><span> 《Bayesian Modeling and Computation in Python》</span></a></li><li><a class="site-page child" href="https://xishansnow.github.io/ElementsOfStatisticalLearning/index.html"><i class="fa-fw fa-solid  fa-book-atlas"></i><span> 《统计学习精要（ESL）》</span></a></li><li><a class="site-page child" href="https://xishansnow.github.io/spatialSTAT_CN/index.html"><i class="fa-fw fa-solid  fa-layer-group"></i><span> 《空间统计学》</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://otexts.com/fppcn/index.html"><i class="fa-fw fa-solid  fa-cloud-sun-rain"></i><span> 《预测：方法与实践》</span></a></li><li><a class="site-page child" href="https://xishansnow.github.io/MLAPP/index.html"><i class="fa-fw fa-solid  fa-robot"></i><span> 《机器学习的概率视角（MLAPP）》</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-compass"></i><span> 索引</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fa-solid fa-timeline"></i><span> 时间索引</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签索引</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类索引</span></a></li></ul></div><div class="menus_item"><a class="site-page group hide" href="javascript:void(0);"><i class="fa-fw fas fa-link"></i><span> 其他</span><i class="fas fa-chevron-down"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/link/food/"><i class="fa-fw fas fa-utensils"></i><span> 美食博主</span></a></li><li><a class="site-page child" href="/link/photography"><i class="fa-fw fas fa-camera"></i><span> 摄影大神</span></a></li><li><a class="site-page child" href="/link/paper/"><i class="fa-fw fas fa-book-open"></i><span> 学术工具</span></a></li><li><a class="site-page child" href="/gallery/"><i class="fa-fw fas fa-images"></i><span> 摄影作品</span></a></li><li><a class="site-page child" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></li></ul></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">RIME配置指南</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2022-04-02T08:30:00.000Z" title="发表于 2022-04-02 16:30:00">2022-04-02</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-12-28T08:47:47.456Z" title="更新于 2022-12-28 16:47:47">2022-12-28</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E4%B8%8E%E4%BD%BF%E7%94%A8/">软件安装与使用</a><i class="fas fa-angle-right post-meta-separator"></i><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E4%B8%8E%E4%BD%BF%E7%94%A8/Linux/">Linux</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">13.7k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>44分钟</span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><script src='https://unpkg.com/tippy.js@2.0.2/dist/tippy.all.min.js'></script>
<script src='/js/attachTooltips.js'></script>
<link rel='stylesheet' href='/css/tippy.css'>
<script src='https://unpkg.com/tippy.js@2.0.2/dist/tippy.all.min.js'></script>
<script src='/js/attachTooltips.js'></script>
<link rel='stylesheet' href='/css/tippy.css'>
<link rel="stylesheet" type="text&#x2F;css" href="https://cdn.jsdelivr.net/hint.css/2.4.1/hint.min.css"><h2 id="1-写在前面">1 写在前面</h2>
<h3 id="适合人群">适合人群</h3>
<p>适合人群：寻找适合自己输入法的人、喜欢折腾的人。</p>
<h3 id="基本概念">基本概念</h3>
<p><strong>Rime</strong> — 不是一种输入法，而是从常见键盘输入法中提炼出来的抽象输入算法框架。 Rime 涵盖了大多数输入法的「 共性 」部分，所以通过不同配置，Rime 可化身为不同输入法。</p>
<p><strong>Rime　输入法方案</strong> — 要让 Rime 实现某种具体输入法的功能，就需要一些数据来描述其工作方式，即定义该输入法的「 个性 」。例如：「汉语拼音」、「注音」、「五笔字型」 等输入法可凭借 Rime 提供的通用设施、通过设定不同工作参数来实现。</p>
<p>本文的重点就是讲解如何制作一套个性化的输入法方案。</p>
<h3 id="为什么要这么繁琐？">为什么要这么繁琐？</h3>
<p>一键就搞掂，则必然选项少、功能单一、可玩性低。</p>
<h2 id="2-准备开工">2 准备开工</h2>
<h3 id="2-1-Rime-的主要发行版">2.1 Rime 的主要发行版</h3>
<p>Rime 是跨平台的输入法软件，本文介绍的 Rime　输入法方案通用于以下发行版：</p>
<ul>
<li>【中州韵】 ibus-rime → Linux / fcitx-rime / fcitx5-rime</li>
<li>【小狼毫】 Weasel → Windows</li>
<li>【鼠鬚管】 Squirrel → Mac OS X</li>
</ul>
<p>你可以根据自身操作系统安装最新版的 Rime 输入法 ！！！</p>
<h3 id="2-2-Rime-采用文本文件做定制">2.2 Rime 采用文本文件做定制</h3>
<p>Rime 的配置文件、输入法方案定义及词典文件，均为特定格式的文本文件。因此，只需要一款够专业的 <strong>文本编辑器</strong> ，就可以设计 Rime Schema。 Rime 中的所有文本文件，均要求以 UTF-8 编码，并建议使用 UNIX 换行符（LF）。</p>
<p>鉴于一些文本编辑器会为 UTF-8 编码的文件自动添加 BOM 标记，为防止误将该字符混入文中，请不要从文件的第一行开始正文，建议在第一行的行首以 # 记号起一行注释，如：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Rime default settings</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Rime schema: My First Cool Schema</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># Rime dictionary: Lingua Latina</span></span><br></pre></td></tr></table></figure>
<p>当然也可继续以注释行写下方案简介、码表来源、制作者、修订记录等信息，然后再切入正文。</p>
<h3 id="2-3-文本文件的格式">2.3 文本文件的格式</h3>
<p>Rime 输入法采用扩展名为「<code>.yaml</code>」的文本文件，以　YAML　数据描述语言编写。请访问 <a target="_blank" rel="noopener" href="http://yaml.org/">http://yaml.org/</a> 了解 YAML 文件格式。下文只对部分语法作简要说明，而将重点放在对　Rime 语义的解读上。</p>
<p>Rime 输入法方案的配置文件中亦会用到「　正则表达式　」实现一些高级功能。您需要掌握这份文件所描述的 <a target="_blank" rel="noopener" href="http://www.boost.org/doc/libs/1_49_0/libs/regex/doc/html/boost_regex/syntax/perl_syntax.html">Perl 正则表达式语法</a>。</p>
<h3 id="2-4-Rime-的文件分布及作用">2.4 Rime 的文件分布及作用</h3>
<p>除执行程序以外，Rime 还包括多种数据文件。这些数据文件主要存储在两个位置：</p>
<p><a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/SharedData">全用户共享文件夹</a></p>
<ul>
<li>【中州韵】  <code>/usr/share/rime-data/</code></li>
<li>【小狼毫】  <code>&quot;安装目录\data&quot;</code></li>
<li>【鼠鬚管】  <code>&quot;/Library/Input Methods/Squirrel.app/Contents/SharedSupport/&quot;</code></li>
</ul>
<p><a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/UserData">用户私人文件夹</a></p>
<ul>
<li>【中州韵】
<ul>
<li><code>ibus</code> 为 <code>~/.config/ibus/rime/</code></li>
<li><code>fcitx5</code> 为 <code>~/.local/fcitx5/rime/</code></li>
</ul>
</li>
<li>【小狼毫】  <code>%APPDATA%\Rime</code></li>
<li>【鼠鬚管】  <code>~/Library/Rime/</code></li>
</ul>
<p><a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/SharedData">共享资料夹</a> 包含默认输入法方案的源文件。这些文件属于 Rime 发行软件的一部份，在访问权限控制较严格的系统上对用户是只读的，因此谢绝软件版本更新以外的任何修改。一旦用户修改这里的文件，很可能影响后续的软件升级或在升级时丢失数据。在执行「<a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/CustomizationGuide#%E9%87%8D%E6%96%B0%E4%BD%88%E7%BD%B2%E7%9A%84%E6%93%8D%E4%BD%9C%E6%96%B9%E6%B3%95">部署</a>」操作时，将用到这里的输入法方案源文件、并结合用户定制的内容来编译默认输入法方案。</p>
<p><a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/UserData">用户资料夹</a> 则包含为用户准备的内容，如：</p>
<ul>
<li>〔全局配置文件〕 <code>default.yaml</code></li>
<li>〔发行版的配置文件〕 <code>weasel.yaml</code></li>
<li>〔输入法方案的配置文件〕 <code>&lt;方案标识&gt;.schema.yaml</code></li>
<li>※〔安装信息〕 <code>installation.yaml</code></li>
<li>※〔用户状态信息〕 <code>user.yaml</code></li>
</ul>
<p>编译输入法方案所产出的二进制文件：</p>
<ul>
<li>〔Rime 棱镜〕 <code>&lt;方案标识&gt;.prism.bin</code></li>
<li>〔Rime 固态词典〕 <code>&lt;词典名&gt;.table.bin</code></li>
<li>〔Rime 反查词典〕 <code>&lt;词典名&gt;.reverse.bin</code></li>
</ul>
<p>记录用户写作习惯的文件：</p>
<ul>
<li>※〔用户词典〕 <code>&lt;词典名&gt;.userdb/</code> 或 <code>&lt;词典名&gt;.userdb.kct</code></li>
<li>※〔用户词典快照〕 <code>&lt;词典名&gt;.userdb.txt</code>、<code>&lt;词典名&gt;.userdb.kct.snapshot</code> 见于同步文件夹</li>
</ul>
<p>以及用户自己设置的：</p>
<ul>
<li>※〔用户对全局设置的定制信息〕 <code>default.custom.yaml</code></li>
<li>※〔用户对默认输入法方案的定制信息〕 <code>&lt;方案标识&gt;.custom.yaml</code></li>
<li>※〔用户自制输入法方案〕及配套的词典源文件</li>
</ul>
<p>注：以上标有 ※ 号的文件，为用户个性化的重要资料，您在清理文件时要注意备份！</p>
<h2 id="3-详解输入法方案">3 详解输入法方案</h2>
<p>一套输入法方案，通常包含「方案定义」文件和「词典」文件。「方案定义」文件命名为 <code>&lt;方案标识&gt;.schema.yaml</code>，是一份包含输入法方案配置信息的 YAML 文件。下面按照板块来介绍该文件的详细设置方法。</p>
<h3 id="3-1-方案描述">3.1 方案描述</h3>
<p>文件中需要有这样一组方案描述：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 以下代码片段节选自 luna_pinyin.schema.yaml</span></span><br><span class="line"></span><br><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="attr">schema_id:</span> <span class="string">luna_pinyin</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">朙月拼音</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;0.9&quot;</span></span><br><span class="line">  <span class="attr">author:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">佛振</span> <span class="string">&lt;chen.sst@gmail.com&gt;</span></span><br><span class="line">  <span class="attr">description:</span> <span class="string">|</span></span><br><span class="line">    <span class="string">Rime</span> <span class="string">默认的拼音输入法方案。</span></span><br></pre></td></tr></table></figure>
<ul>
<li>
<p><strong>方案名称</strong>。<code>schema/name</code> 字段是显示在　Rime〔方案选单〕中的名称。上例中 <code>朙月拼音</code> 即为一个方案名称。</p>
</li>
<li>
<p><strong>方案标识</strong>。每一个输入法方案在整个 Rime 中必须有唯一的「方案标识」，即 <code>schema/schema_id</code> 字段。方案标识由小写字母、数字、下划线构成。该标识仅在 Rime 内部使用，并且是方案定义文件名的组成部分，为了兼容不同文件系统，建议不要用大写字母、汉字、空格和其他符号做方案标识。如上例中，输入法方案的标识为<code>luna_pinyin</code>。</p>
</li>
<li>
<p><strong>方案版本号</strong>。方案如做升级，可以通过版本号（<code>schema/version</code>）来区分新旧版本。版本号是以「.」分隔的整数（或文字）构成的字符串。如果方案的升级会导致原有用户输入习惯无法在新方案中继续使用，应当更换一个新方案标识以示区别。例如：<code>【仓颉五代】之于【仓颉三代】</code>、<code>【五笔 98】之于【五笔 86】</code>，其实都已是互不兼容的输入法。下面是版本号常见的一些形式：</p>
</li>
</ul>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">- <span class="string">&quot;1&quot;</span>      <span class="comment"># 最好加引号表明是字符串！</span></span><br><span class="line">- <span class="string">&quot;1.0&quot;</span>    <span class="comment"># 最好加引号表明是字符串！</span></span><br><span class="line">- <span class="string">&quot;0.9.8&quot;</span></span><br><span class="line">- <span class="string">&quot;0.9.8.custom.86427531&quot;</span>  <span class="comment"># 这是经过用户自定义并自动生成的版本</span></span><br></pre></td></tr></table></figure>
<ul>
<li><strong>方案作者</strong>。采用字段　<code>schema/author</code> 列出作者和主要贡献者，格式为文字列表：</li>
</ul>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="attr">author:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">作者甲</span> <span class="string">&lt;alpha@rime.org&gt;</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">作者乙</span> <span class="string">&lt;beta@rime.org&gt;</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">作者丙</span></span><br></pre></td></tr></table></figure>
<ul>
<li><strong>方案简介</strong>。 采用　<code>schema/description</code> 字段对输入法方案作简要介绍的多行文字。</li>
</ul>
<p>注意：</p>
<p>上述 <code>schema/schema_id</code>、<code>schema/version</code> 字段用于在程序中识别输入法方案，而 <code>schema/name</code>、<code>schema/author</code>、<code>schema/description</code> 则主要是展示给用户的信息。</p>
<h3 id="3-2-输入法引擎与功能组件">3.2 输入法引擎与功能组件</h3>
<p>除了　<code>3.1 节</code>　中的方案描述外，方案定义文件中还包含各种功能设置，控制着输入法引擎的工作方式。 Rime 输入法内部的工作流程大致为：</p>
<blockquote>
<p>按键消息 → 后台「服务」 → 分配给对应的「会话」 → 交由「方案选单」或「输入引擎」处理……</p>
</blockquote>
<p>此处的会话指：多窗口、多线程操作，例如同时与好几位 MM 聊天，会产生好几组会话。每一组会话中都有一部输入引擎来完成从按键序列到文字的转换过程。Rime 支持在不同会话中使用「方案选单」指定的不同输入引擎。「方案选单」本身可以响应一些按键，但大多数时候都是把按键传递给「输入引擎」做处理，也就是说真正做处理的是本节要介绍的「输入引擎」。</p>
<p><code>输入引擎</code> 内部的工作流程大致如下：</p>
<blockquote>
<p>加载输入法方案/预备功能组件 --&gt; 进入处理按键消息、处理按键消息的循环。</p>
</blockquote>
<p>在输入引擎中，响应各种按键并产生效果的工作，由不同功能组件分担。例如代码：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># luna_pinyin.schema.yaml</span></span><br><span class="line"><span class="comment"># ...</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span>                    <span class="comment"># 输入引擎设置，即挂接组件的「处方」</span></span><br><span class="line">  <span class="attr">processors:</span>              <span class="comment"># 一、这批组件处理各类按键消息</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">ascii_composer</span>       <span class="comment"># ※ 处理西文模式及中西文切换</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">recognizer</span>           <span class="comment"># ※ 与 matcher 搭配，处理符合特定规则的输入码，如网址、反查等</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">key_binder</span>           <span class="comment"># ※ 在特定条件下将按键绑定到其他按键，如重定义逗号、句号为候选翻页键</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">speller</span>              <span class="comment"># ※ 拼写处理器，接受字符按键，编辑输入码</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punctuator</span>           <span class="comment"># ※ 句读处理器，将单个字符按键直接映射为文字符号</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">selector</span>             <span class="comment"># ※ 选字处理器，处理数字选字键、上、下候选定位、换页键</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">navigator</span>            <span class="comment"># ※ 处理输入栏内的光标移动键</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span>       <span class="comment"># ※ 编辑器，处理空格、回车上屏、回退键等</span></span><br><span class="line">  <span class="attr">segmentors:</span>              <span class="comment"># 二、这批组件识别不同内容类型，将输入码分段</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">ascii_segmentor</span>      <span class="comment"># ※ 标识西文段落</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">matcher</span>              <span class="comment"># ※ 标识符合特定规则的段落，如网址、反查等</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">abc_segmentor</span>        <span class="comment"># ※ 标识常规的文字段落</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_segmentor</span>      <span class="comment"># ※ 标识句读段落</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">fallback_segmentor</span>   <span class="comment"># ※ 标识其他未标识段落</span></span><br><span class="line">  <span class="attr">translators:</span>             <span class="comment"># 三、这批组件翻译特定类型的编码段为一组候选文字</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">echo_translator</span>      <span class="comment"># ※ 没有其他候选字时，回显输入码</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_translator</span>     <span class="comment"># ※ 转换标点符号</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">script_translator</span>    <span class="comment"># ※ 脚本翻译器，用于拼音等基于音节表的输入法方案</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">reverse_lookup_translator</span>  <span class="comment"># ※ 反查翻译器，用另一种编码方案查码</span></span><br><span class="line">  <span class="attr">filters:</span>                 <span class="comment"># 四、这批组件过滤翻译的结果</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">simplifier</span>           <span class="comment"># ※ 繁简转换</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">uniquifier</span>           <span class="comment"># ※ 过滤重复的候选字，有可能来自繁简转换</span></span><br></pre></td></tr></table></figure>
<p>注：除了示例代码中引用的组件外，尚有</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="bullet">-</span> <span class="string">fluid_editor</span>      <span class="comment"># ※ 句式编辑器，用于以空格断词、回车上屏的【注音】、【语句流】等输入法方案，替换 express_editor，也可以写作 fluency_editor</span></span><br><span class="line"><span class="bullet">-</span> <span class="string">chord_composer</span>    <span class="comment"># ※ 和絃作曲家或曰并击处理器，用于【宫保拼音】等多键并击的输入法方案</span></span><br><span class="line"><span class="bullet">-</span> <span class="string">table_translator</span>  <span class="comment"># ※ 码表翻译器，用于仓颉、五笔等基于码表的输入法方案，替换 script_translator</span></span><br></pre></td></tr></table></figure>
<p>输入引擎把完成具体功能的逻辑拆分为可装卸、组合的部件。在加载输入法方案时，按照配置文件给出的配方挂接所需的各种功能组件、加载各自设置，并准备执行各自的动作。所有功能组件接下来要完成的任务，均由输入引擎收到的某个按键消息触发。</p>
<p>从总体上看，输入引擎以按键消息为输入，其主要输出三个部分的内容：</p>
<ul>
<li>一是对系统按键消息的响应，如反馈给操作系统 <code>接受</code> 还是 <code>拒绝</code> 按键消息。</li>
<li>二是暂存于输入法、尚未完成处理的内容，会展现在输入法候选窗中。</li>
<li>三是要「上屏」的文字，并不是每按一键都有输出。通常中文字会伴随「确认」动作而上屏，有些按键也会直接导致符号上屏，但这要视具体场景而定。</li>
</ul>
<h4 id="3-2-1-Processors-功能组件">3.2.1 Processors 功能组件</h4>
<p>第一类功能组件 <code>processor</code>，起着比较笼统地、「处理」按键消息的作用。</p>
<p>按键消息依次送往列表中的 <code>processor</code>，由他给出对按键的三种可能处理意见之一：</p>
<ul>
<li>「收」：即由 Rime 响应该按键；</li>
<li>「拒」：回禀操作系统 Rime 不做响应、请对按键做默认处理；</li>
<li>「转」：这个按键我不认得、请下一个 <code>processor</code> 继续处理。</li>
</ul>
<p>优先级依照 <code>processors</code> 列表顺序排列，接收按键者会针对按键消息做处理。</p>
<p>虽然看起来 <code>processor</code> 通过组合可以承担引擎的全部任务，但为了将逻辑继续细分、Rime 又为引擎设置了另外三类功能组件。这些组件都可以访问引擎中的数据对象（即输入上下文），并将各自所做处理的阶段成果存于其中。</p>
<p><code>processor</code> 最常见的处理，便是将按键所产生的字符记入上下文中的「输入码」序列。<br>
当「输入码」发生变更时，下一组组件 <code>segmentors</code> 开始一轮新的作业。</p>
<h4 id="3-2-2-Segmentors-功能组件">3.2.2 Segmentors 功能组件</h4>
<p>Rime 可对包含文字、数字、符号等不同内容的连续输入码进行识别，将其划分成若干段分而治之。这可以通过对整个输入序列代码的多轮划分操作完成。在每一轮中，所有 <code>segmentor</code> 各自识别起始于某一处、符合特定格式的编码段，并其中最长的编码段作为本轮划分的结果，给出此划分的（一个或多个） <code>segmentor</code> 组件则为该编码段打上「类型标签」；然后从此新编码段的结束位置，开始下一轮划分，直到整个输入码序列划分完毕。</p>
<p>举例来说，【朙月拼音】中，输入码 <code>2012nian\</code>，划分为三个编码段：<code>2012</code>（　被打上 <code>number</code> 标签）、<code>nian</code>（　被打上 <code>abc</code> 标签）、<code>\</code>（被打上 <code>punct</code> 标签）。</p>
<p>这些标签是初步划分后判定的类型，也可能有一个编码段被打上多个标签的情况。下一个阶段中，<code>translator</code> 会把特定类型的编码段翻译为文字。</p>
<h4 id="3-2-3-Translators-功能组件">3.2.3 Translators 功能组件</h4>
<p>顾名思义，<code>translator</code> 完成由编码到文字的翻译。但有几个要点：</p>
<ul>
<li>一、翻译的对象是划分好的一个编码段。</li>
<li>二、某个 <code>translator</code> 组件往往只翻译具有特定标签的编码段。</li>
<li>三、翻译结果可能有多条，每条结果都会成为展现给用户的候选项。</li>
<li>四、同一编码段可由多个 <code>translator</code> 分别翻译，其翻译结果按一定规则合并为候选。</li>
<li>五、候选项所对应的编码未必是整个编码段。用拼音敲一个词组时，词组后面继续列出单字候选就是这种情况。</li>
</ul>
<p>下表给出了内存中编码段、标签和翻译结果的可视化示例：</p>
<pre><code>input | tag    | translations
------+--------+-------------------------------------
2012  | number | [ &quot;2012&quot; ], [ &quot;二〇一二&quot; ]
nian  | abc    | [ &quot;年&quot;, &quot;念&quot;, &quot;唸&quot;,... ], [ &quot;nian&quot; ]
\     | punct  | [ &quot;、&quot;, &quot;\&quot; ]
</code></pre>
<p>一个输入串可被划分为多个编码段、每段编码又可具有多组翻译结果；取各编码段的首选结果连接起来，就是预备上屏的文字「<code>2012 年、</code>」。可以将上述示例数据视为一篇未定稿的「作文」，输入法界面此时会显示预备上屏的文字「<code>2012 年、</code>」，并列出最末一个编码段上的候选「<code>、</code>」及「<code>\</code>」以供选择。</p>
<p>有两款主力 <code>translator</code> 完成了大部分文字内容翻译工作，其实现方式很不一样：</p>
<ul>
<li><code>script_translator</code> ：也叫做 <code>r10n_translator</code>，主要实现罗马字分析法，以「固定音节表」为算法基础，识别输入码的音节构成，推敲排列组合、完成遣词造句。</li>
<li><code>table_translator</code> ：主要实现码表方法，基于规则的动态码表，构成编码空间内一个开放的编码集合。</li>
</ul>
<p>拼音、注音、方言拼音等皆是以 <code>固定音节表</code> 上的拼写为基础，通过排列组合方式产生编码，故适用罗马字分析法。而仓颉、五笔字型之类则是适用于码表输入法。</p>
<p>如果以码表方式来写拼音输入法方案，是怎样的效果呢？虽然仍可完成输入，但无法完全实现支持简拼、模糊拼音、使用隔音符号的动态调频、智能语句等特性。</p>
<p>以罗马字方式使用码表输入法，则无法实现定长编码顶字上屏、按编码规则构词等功能。在 Rime 各发行版默认输入法方案中，有一款「速成」输入法方案，即是用 <code>script_translator</code> 翻译仓颉码，从而实现全、简码混合的语句输入。</p>
<p>总结起来，这是两种构造新编码的方式：</p>
<ul>
<li>罗马字式输入法方案以一组固定的基本音节码为基础，通过构造新组合而构词；</li>
<li>码表式输入法方案则以一定码长为限，通过构造新编码映射而构词。</li>
</ul>
<h4 id="3-2-4-Filters-功能组件">3.2.4 Filters 功能组件</h4>
<p>上一步已经收集到各个编码段的翻译结果，当输入法需要在界面中呈现一页候选项时，就会从最末一个编码段的结果集中挑选，直至取够方案定义文件中指定的<code>页最大候选数</code>。</p>
<p>在翻译结果进入候选序列之前，Rime 会对从结果集中选出每一条字词，做一组 <code>filter</code> 过滤。多个 <code>filter</code> 串行工作，进入候选序列的是串行过滤最终产出的结果。</p>
<p><code>filter</code> 可以：</p>
<ul>
<li>改装正在处理的候选项，修改某些属性值：简化字、火星文、菊花文有无有？</li>
<li>消除当前候选项，比如检测到重复（由不同 <code>translator</code> 产生）的候选条目</li>
<li>插入新的候选项，比如根据已有条目插入关联的结果</li>
<li>修改已有的候选序列</li>
</ul>
<h3 id="3-3-词典文件与码表">3.3 词典文件与码表</h3>
<h4 id="3-3-1-词典文件">3.3.1 词典文件</h4>
<p>词典是 <code>translator</code> 的参考书，通常与同名的输入法方案配套使用，如拼音输入法的词典以拼音码查字，仓颉输入法的词典以仓颉码查字。但也可以由若干编码属于同一系统的输入法方案共用，如各种双拼方案都会使用和拼音同样的词典，不仅可以复用码表数据，也可以共享用户录入的自造词。</p>
<p>Rime 的词典文件，命名为 <code>&lt;词典名&gt;.dict.yaml</code>，包含一份 <code>码表</code> 及对应的 <code>规则说明</code>。　词典文件的前半部份为 YAML 语法的<code>规则说明</code>：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">name:</span> <span class="string">luna_pinyin</span></span><br><span class="line"><span class="attr">version:</span> <span class="string">&quot;0.9&quot;</span></span><br><span class="line"><span class="attr">sort:</span> <span class="string">by_weight</span></span><br><span class="line"><span class="attr">use_preset_vocabulary:</span> <span class="literal">true</span></span><br><span class="line"><span class="string">...</span></span><br><span class="line"><span class="meta">---</span></span><br></pre></td></tr></table></figure>
<p>解释：</p>
<ul>
<li><code>name</code>: 内部使用的词典名，命名原则与「方案标识」一致，但可以与其配套的输入法方案标识不同；</li>
<li><code>version</code>: 管理词典的版本，规则同输入法方案定义文件中的版本号；</li>
<li><code>sort</code>: 词条初始排序方式，可选填 <code>by_weight</code>（按词频高低排序）或 <code>original</code>（保持原码表中的顺序）；</li>
<li><code>use_preset_vocabulary</code>: 填 <code>true</code> 或 <code>false</code>，选择是否导入默认词汇表【八股文】。</li>
</ul>
<h4 id="3-3-2-码表">3.3.2 码表</h4>
<p>码表定义了输入法中编码与文字之间的对应关系。码表位于词典文件中 YAML 结束标记之后的部份。其格式为：以 <code>制表符分隔</code> 的值，每行定义一条「文字－编码」的对应关系：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># 单字</span></span><br><span class="line"><span class="string">你</span>	<span class="string">ni</span></span><br><span class="line"><span class="string">我</span>	<span class="string">wo</span></span><br><span class="line"><span class="string">的</span>	<span class="string">de</span>	<span class="number">99</span><span class="string">%</span></span><br><span class="line"><span class="string">的</span>	<span class="string">di</span>	<span class="number">1</span><span class="string">%</span></span><br><span class="line"><span class="string">地</span>	<span class="string">de</span>	<span class="number">10</span><span class="string">%</span></span><br><span class="line"><span class="string">地</span>	<span class="string">di</span>	<span class="number">90</span><span class="string">%</span></span><br><span class="line"><span class="string">目</span>	<span class="string">mu</span></span><br><span class="line"><span class="string">好</span>	<span class="string">hao</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 词组</span></span><br><span class="line"><span class="string">你我</span></span><br><span class="line"><span class="string">你的</span></span><br><span class="line"><span class="string">我的</span></span><br><span class="line"><span class="string">我的天</span></span><br><span class="line"><span class="string">天地</span>	<span class="string">tian</span> <span class="string">di</span></span><br><span class="line"><span class="string">好天</span></span><br><span class="line"><span class="string">好好地</span></span><br><span class="line"><span class="string">目的</span>	<span class="string">mu</span> <span class="string">di</span></span><br><span class="line"><span class="string">目的地</span>	<span class="string">mu</span> <span class="string">di</span> <span class="string">di</span></span><br></pre></td></tr></table></figure>
<blockquote>
<p>※注意：</p>
<p><strong>不要</strong> 从网页复制以上代码到实际的词典文件中！因为网页里的制表符会被转换成空格，不符合 Rime 词典的格式要求。一些文本编辑器也会将制表符自动转换为空格，请注意检查和设置。</p>
</blockquote>
<p>码表部份，除了以上格式的编码行，还可以包含空行（不含任何字符）及注释行（行首为 # 符号）。</p>
<ul>
<li><strong>文字</strong>：以制表符分隔的第一个字段是所定义的文字，可以是单字或词组；</li>
<li><strong>编码</strong>：第二个字段是与文字对应的编码；若该编码由多个「音节」组成，音节之间以 <code>空格</code> 分开；</li>
<li><strong>频度</strong>：第三个字段为可选项，表示该字词的权重频度值（非负整数），或相对于默认权值的百分比（浮点数 %）。在拼音输入法中，往往多音字的若干种读音使用的场合不同，于是指定不同百分比来修正每个读音的使用频度。</li>
</ul>
<p>词组如果满足以下条件，则可以省去编码字段：</p>
<ul>
<li>词组中每个单字均有编码定义</li>
<li>词组中不包含多音字（例：你我），或多音字在该词组中读音的权值超过该多音字全部读音权值的 5%（例：我的）</li>
</ul>
<p>因为，此时词组的编码可由单字编码的组合推导出来。</p>
<p>反之，则有必要给出词组的编码以消除自动注音的不确定性（例：天地）。</p>
<p>当含有多音字的词组缺少编码字段时，自动注音程序会利用权重百分比高于 5% 的读音进行组合、生成全部可能的注音，如：</p>
<p>「好好地」在编译时自动注音为「<code>hao hao de</code>」、「<code>hao hao di</code>」</p>
<h3 id="3-4-设置项速查手册">3.4 设置项速查手册</h3>
<p><a target="_blank" rel="noopener" href="https://github.com/LEOYoon-Tsaw/Rime_collections/blob/master/Rime_description.md">雪斋的文件</a> 全面而详细解释了输入法方案及词典中各设置项的含义及用法。</p>
<h3 id="3-5-八股文">3.5 八股文</h3>
<p>Rime 有一份名为【八股文】的默认词汇表。</p>
<p>多数输入法方案需要用到一些标准白话文中的通用词汇。为免重复在每份码表中包含这些词汇，减少输入法方案维护成本，Rime 提供了一份默认词汇表及自动编码（注音）的设施。</p>
<p>创作输入法方案时，如果希望完全控制词汇表的内容而不采用【八股文】中的词组，只须直接将词汇编入码表即可。</p>
<p>否则，在词典文件中设置 <code>use_preset_vocabulary: true</code> 将【八股文】导入该词典；<br>
在码表中给出单字码、需要分辨多音字的词组编码、以及该输入法方案特有的词汇，其他交给自动注音来做就好啦。</p>
<p>Rime 默认输入法方案正是利用这份词汇表及自动注音工具，在不牺牲效果及可维护性的前提下、使词典文件压缩到最小的行数。</p>
<p>【八股文】包含从 CC-CEDICT、新酷音等开源项目中整理出来的约二十三万条词汇，其用字及词频数据针对传统汉字做过调整。因此基于这份词汇表产生的输入结果，比较接近以传统汉字行文的实际用法。</p>
<p>为了充分利用【八股文】提供的词汇，自定义的词典应保证单字码表收录了符合 opencc 字形标准的常用字。特别注意，该标准对以下几组异体字的取舍，【八股文】将这些字（包括词组及字频）统一到左边一列的字形。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line">为	为</span><br><span class="line">伪	伪</span><br><span class="line">嬀	妫</span><br><span class="line">潙	沩</span><br><span class="line">凶	凶</span><br><span class="line">启	启</span><br><span class="line">棱	稜</span><br><span class="line">污	污</span><br><span class="line">泄	洩</span><br><span class="line">涌	涌</span><br><span class="line">牀	床</span><br><span class="line">着	着</span><br><span class="line">灶	灶</span><br><span class="line">众	众</span><br><span class="line">里	里</span><br><span class="line">踊	踊</span><br><span class="line">麪	面</span><br><span class="line">羣	群</span><br><span class="line">峯	峰</span><br></pre></td></tr></table></figure>
<p>请务必在码表中收录左列的单字；并建议收全右列的单字。</p>
<p>输入法词典往往对下列几组字不做严格区分，opencc 则倾向于细分异体字的不同用法。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">喫	吃</span><br><span class="line">霉	霉</span><br><span class="line">攷	考</span><br><span class="line">覈	核</span><br></pre></td></tr></table></figure>
<p>请尽量在码表中收全以上单字。</p>
<p>部署过程中，未能完成自动注音的字、词会以警告形式出现在日志文件里。如果所报告的字为生僻字、您可以忽略他；如果警告中大量出现某个常用字，那么应该注意到码表里缺失了该字的注音。</p>
<h3 id="3-6-编译输入法方案">3.6 编译输入法方案</h3>
<p>将写好的输入法方案布署到 Rime 输入法的过程，称为「编译」：</p>
<p>为查询效率故，输入法工作时不直接加载文本格式的词典源文件，而要在编译过程中，为输入法方案生成专为高速查询设计的「.bin」文件。</p>
<p>编译时程序做以下几件事：</p>
<ul>
<li>将用户的定制内容合併到输入法方案定义中，在用户资料夹生成 .schema.yaml 文件副本；</li>
<li>依照输入法方案中指定的词典：求得音节表（不同种编码的集合）、单字表；</li>
<li>对词典中未提供编码的词组自动注音，也包括从【八股文】导入的词组；</li>
<li>建立按音节编码检索词条的索引，制作 Rime 固态词典；</li>
<li>建立按词条检索编码的索引，制作 Rime 反查词典；</li>
<li>依照音节表和方案定义中指定的拼写运算规则，制作 Rime 棱镜。</li>
</ul>
<h3 id="3-7-布署-Rime">3.7 布署 Rime</h3>
<p>初次安装 Rime 输入法，无有任何输入法方案和用户设置。因此安装的最后一个步骤即是把发行版默认的输入法方案和设置文件布署到 Rime 为该用户创建的工作目录，至此 Rime 才成为一部可以发动的输入引擎。</p>
<p>此后无论是修改已有方案的设置，或是添加了新的输入法方案，都需要「重新布署」成功后方可使用户的新设置作用于 Rime 输入法。</p>
<p>〔★〕重新布署的方法是：</p>
<ul>
<li>【小狼毫】从开始菜单选择「重新部署」；或当开启托盘图标时，在托盘图标上右键选择「重新布署」；</li>
<li>【鼠鬚管】在系统语言文字选单中选择「重新布署」；</li>
<li>【中州韵】点击输入法状态栏（或 IBus 菜单）上的 ⟲ (Deploy) 按钮；</li>
<li>早于 ibus-rime 0.9.2 的版本：删除用户资料夹的 <code>default.yaml</code> 之后、执行 <code>ibus-daemon -drx</code> 重载 IBus</li>
</ul>
<h2 id="4-定制指南">4 定制指南</h2>
<p>Rime 输入法方案，将 Rime 输入法的设置整理成完善的、可分发的形式。但并非一定要创作新的输入法方案，才可以改变 Rime 的行为。当用户需要对 Rime 中的各种设置做小幅的调节，最直接、但不完全正确的做法是：编辑用户资料夹中那些 .yaml 文件。</p>
<p>这一方法有弊端：</p>
<ul>
<li>当 Rime 软件升级时，也会升级各种设置档、默认输入法方案。用户编辑过的文件会被覆写为更高版本，所做调整也便丢失了。</li>
<li>即使在软件升级后再手动恢复经过编辑的文件，也会因设置档的其他部分未得到更新而失去本次升级新增和修复的功能。</li>
</ul>
<p>因此，对于随 Rime 发行的设置档及默认输入法方案，推荐的定制方法是：</p>
<p>创建一个文件名的主体部份（　即「.」之前的部分　）与要定制的文件相同、次级扩展名（　即扩展名「.yaml」之前的部分　）为 <code>.custom</code> 的定制文件，如：<code>default.yaml</code> --&gt; <code>default.custom.yaml</code> 。 该文件应当用　<code>patch</code> 关键字定义一组设置的「补丁」，Rime 会对源文件中的相同设置进行替换、或写入新的设置项。例如：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">patch:</span></span><br><span class="line">  <span class="string">&quot;一级设置项/二级设置项/三级设置项&quot;</span><span class="string">:</span> <span class="string">新的设置值</span></span><br><span class="line">  <span class="string">&quot;另一个设置项&quot;</span><span class="string">:</span> <span class="string">新的设置值</span></span><br><span class="line">  <span class="string">&quot;再一个设置项&quot;</span><span class="string">:</span> <span class="string">新的设置值</span></span><br><span class="line">  <span class="string">&quot;含列表的设置项/@0&quot;</span><span class="string">:</span> <span class="string">列表第一个元素新的设置值</span></span><br><span class="line">  <span class="string">&quot;含列表的设置项/@last&quot;</span><span class="string">:</span> <span class="string">列表最后一个元素新的设置值</span></span><br><span class="line">  <span class="string">&quot;含列表的设置项/@before 0&quot;</span><span class="string">:</span> <span class="string">在列表第一个元素之前插入新的设置值（不建议在补靪中使用）</span></span><br><span class="line">  <span class="string">&quot;含列表的设置项/@after last&quot;</span><span class="string">:</span> <span class="string">在列表最后一个元素之后插入新的设置值（不建议在补靪中使用）</span></span><br><span class="line">  <span class="string">&quot;含列表的设置项/@next&quot;</span><span class="string">:</span> <span class="string">在列表最后一个元素之后插入新的设置值（不建议在补靪中使用）</span></span><br></pre></td></tr></table></figure>
<p>以下这些例子，另载于 <a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/CustomizationGuide">《定制指南》</a>，其中所介绍的知识和技巧，覆盖了不少本文未讨论的细节，应当会对创作新的输入法方案有所启发。</p>
<ul>
<li>例１：<a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/CustomizationGuide#%E4%B8%80%E4%BE%8B%E5%AE%9A%E8%A3%BD%E6%AF%8F%E9%A0%81%E5%80%99%E9%81%B8%E6%95%B8">定制每页候选数</a></li>
<li>例２：<a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/CustomizationGuide#%E4%B8%80%E4%BE%8B%E5%AE%9A%E8%A3%BD%E6%A8%99%E9%BB%9E%E7%AC%A6%E8%99%9F">定制标点符号</a></li>
<li>例３：<a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/CustomizationGuide#%E4%B8%80%E4%BE%8B%E5%AE%9A%E8%A3%BD%E7%B0%A1%E5%8C%96%E5%AD%97%E8%BC%B8%E5%87%BA">定制简化字输出</a></li>
<li>例４：<a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/CustomizationGuide#%E4%B8%80%E4%BE%8B%E9%BB%98%E8%AA%8D%E8%8B%B1%E6%96%87%E8%BC%B8%E5%87%BA">默认英文输出</a></li>
<li>例５：<a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/CustomizationGuide#%E4%B8%80%E4%BE%8B%E5%AE%9A%E8%A3%BD%E6%96%B9%E6%A1%88%E9%81%B8%E5%96%AE">定制方案选单</a></li>
</ul>
<p>重要！创作了新的输入法方案，最后一步就是在「方案选单」里启用他。</p>
<h1>拼写运算</h1>
<p>应该算是 Rime 输入法最主要的独创技术。</p>
<p>概括来说就是将方案中的编码通过规则映射到一组全新的拼写形式！<br>
也就是说能让 Rime 输入法方案在不修改码表的情况下、适应不同的输入习惯。</p>
<p>拼写运算能用来：</p>
<ul>
<li>改革拼写法
<ul>
<li>将编码映射到基于同一音系的其他拼写法，如注音、拼音、普通话罗马字相互转换</li>
<li>重定义注音键盘、双拼方案</li>
</ul>
</li>
<li>实现简拼查询</li>
<li>在音节表上灵活地定义模糊音规则</li>
<li>实现音节自动纠错</li>
<li>变换回显的输入码或提示码，如将输入码显示为字根、注音符号、带声调标注的罗马字</li>
</ul>
<p>给力吗？</p>
<p>[[★这里|SpellingAlgebra]] 有介绍拼写运算的专题文章。</p>
<h1>综合演练</h1>
<p>如果你安装好了 Rime 却不会玩，就一步一步跟我学吧。</p>
<p>本系列课程每个步骤的完整代码可由此查阅：</p>
<p><a target="_blank" rel="noopener" href="https://github.com/lotem/rimeime/tree/master/doc/tutorial">https://github.com/lotem/rimeime/tree/master/doc/tutorial</a></p>
<h2 id="【一】破空中出鞘">【一】破空中出鞘</h2>
<h3 id="Hello-Rime">Hello, Rime!</h3>
<p>第一个例子，总是最简单的（也是最傻的）。</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Rime schema</span></span><br><span class="line"><span class="comment"># encoding: utf-8</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"><span class="comment"># 最简单的 Rime 输入法方案</span></span><br><span class="line"><span class="comment">#</span></span><br><span class="line"></span><br><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="attr">schema_id:</span> <span class="string">hello</span>    <span class="comment"># 注意此 ID 与文件名里 .schema.yaml 之前的部分相同</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">大家好</span>        <span class="comment"># 将在〔方案选单〕中显示</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;1&quot;</span>        <span class="comment"># 这是文字类型而非整数或小数，如 &quot;1.2.3&quot;</span></span><br></pre></td></tr></table></figure>
<p>起首几行是注释。而后只有一组必要的方案描述信息。</p>
<p>这一课主要练习建立格式正确的 YAML 文件。</p>
<ul>
<li>要点一，让你的文本编辑器以 UTF-8 编码保存该文件；</li>
<li>要点二，注意将 <code>schema:</code> 之下的三行代码以空格缩进——我的习惯是用两个空格——而 <strong>不要</strong> 用 Tab 字符来缩进。</li>
</ul>
<p>缩进表示设置项所属的层次。在他处引用到此文件中的设置项，可分别以 <code>schema/schema_id</code>, <code>schema/name</code>, <code>schema/version</code> 来指称。</p>
<p>我现在把写好的方案文件命名为 <code>hello.schema.yaml</code>，丢进<a target="_blank" rel="noopener" href="https://github.com/rime/home/wiki/UserData">用户资料夹</a>，只要这一个文件就妥了；</p>
<p>然后，启用他。有些版本会有「方案选单设置」这个界面，在那里勾选【大家好】这个方案即可。若无有设置界面，则按照上文《定制方案选单》一节来做。</p>
<p>好运！我已建立了一款名为【大家好】的新方案！虽然他没有实现任何效果、按键仍会像无有输入法一样直接输出西文。</p>
<h3 id="开始改装">开始改装</h3>
<p>为了处理字符按键、生成输入码，本例向输入引擎添加两个功能组件。</p>
<p>以下代码仍是 ID 为 <code>hello</code> 的新款输入法方案，但增加了 <code>schema/version</code> 的数值。<br>
以后每个版本，都以前一个版本为基础改写，引文略去无有改动的部分，以突出重点。</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># ...</span></span><br><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="attr">schema_id:</span> <span class="string">hello</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">大家好</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;2&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">fluid_editor</span></span><br><span class="line">  <span class="attr">segmentors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">fallback_segmentor</span></span><br></pre></td></tr></table></figure>
<p><code>fluid_editor</code> 将字符按键记入输入上下文，<code>fallback_segmentor</code> 将输入码连缀成一段。于是重新布署后，按下字符键不再直接上屏，而显示为输入码。</p>
<p>你会发现，该输入法只是收集了键盘上的可打印字符，并于按下空格、回车键时令输入码上屏。</p>
<p>现在就好似写输入法程序的过程中，将将取得一小点成果，还有很多逻辑未实现。不同的是，在 Rime 输入法方案里写一行代码，顶 Rime 开发者所写的上百上千行。因此我可以很快地组合各种逻辑组件、搭建出心里想的输入法。</p>
<h3 id="创建候选项">创建候选项</h3>
<p>第二版的【大家好】将键盘上所有字符都记入输入码，这对整句输入有用，但是时下流行输入法只处理编码字符、其他字符直接上屏的形式。为了对编码字符做出区分，以下改用 <code>speller</code> + <code>express_editor</code> 的组合取代 <code>fluid_editor</code>：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># ...</span></span><br><span class="line"></span><br><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="comment"># ...</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;3&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">speller</span>          <span class="comment"># 把字母追加到编码串</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span>   <span class="comment"># 空格确认当前输入、其他字符直接上屏</span></span><br><span class="line">  <span class="attr">segmentors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">fallback_segmentor</span></span><br></pre></td></tr></table></figure>
<p><code>speller</code> 默认只接受小写拉丁字母作为输入码。<br>
试试看，输入其他字符如大写字母、数字、标点，都会直接上屏。并且如果已经输入了编码时，下一个直接上屏的字符会将输入码顶上屏。</p>
<p>再接着，创建一个最简单的候选项——把编码串本身作为一个选项。故而会提供这个选项的新组件名叫 <code>echo_translator</code>。</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># ...</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="comment"># ...</span></span><br><span class="line">  <span class="attr">translators:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">echo_translator</span>  <span class="comment"># （无有其他结果时，）创建一个与编码串一个模样的候选项</span></span><br></pre></td></tr></table></figure>
<p>至此，【大家好】看上去与一个真正的输入法形似啦。只是还不会打出「大家好」哇？</p>
<h3 id="编写词典">编写词典</h3>
<p>那就写一部词典，码表中设置以 <code>hello</code> 作为短语「大家好」的编码：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Rime dictionary</span></span><br><span class="line"><span class="comment"># encoding: utf-8</span></span><br><span class="line"></span><br><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">name:</span> <span class="string">hello</span></span><br><span class="line"><span class="attr">version:</span> <span class="string">&quot;1&quot;</span></span><br><span class="line"><span class="attr">sort:</span> <span class="string">original</span></span><br><span class="line"><span class="string">...</span></span><br><span class="line"></span><br><span class="line"><span class="string">大家好</span>	<span class="string">hello</span></span><br><span class="line"><span class="string">再见</span>	<span class="string">bye</span></span><br><span class="line"><span class="string">再会</span>	<span class="string">bye</span></span><br></pre></td></tr></table></figure>
<p>※注意： <strong>不要</strong> 从网页复制以上代码到实际的词典文件！因为网页里制表符被转换成空格从而不符合 Rime 词典要求的格式。一些文本编辑器也会将使用者输入的制表符自动转换为空格，请注意检查和设置。</p>
<p>同时修改方案定义：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#...</span></span><br><span class="line"></span><br><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="comment"># ...</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;4&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="comment">#...</span></span><br><span class="line">  <span class="attr">segmentors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">abc_segmentor</span>       <span class="comment"># 标记输入码的类型</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">fallback_segmentor</span></span><br><span class="line">  <span class="attr">translators:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">echo_translator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">table_translator</span>    <span class="comment"># 码表式转换</span></span><br><span class="line"></span><br><span class="line"><span class="attr">translator:</span></span><br><span class="line">  <span class="attr">dictionary:</span> <span class="string">hello</span>       <span class="comment"># 设置 table_translator 使用的词典名</span></span><br></pre></td></tr></table></figure>
<p>工作流程是这样的：</p>
<ul>
<li><code>speller</code> 将字母键加入输入码序列</li>
<li><code>abc_segmentor</code> 给输入码打上标签 <code>abc</code></li>
<li><code>table_translator</code> 把带有 <code>abc</code> 籤的输入码以查表的方式译为中文</li>
<li><code>table_translator</code> 所查的码表在 <code>translator/dictionary</code> 所指定的词典里</li>
</ul>
<p>现在可以敲 <code>hello</code> 而打出「大家好」。完工！</p>
<h3 id="实现选字及换页">实现选字及换页</h3>
<p>等一下。</p>
<p>记得 <code>hello</code> 词典里，还有个编码叫做 <code>bye</code>。敲 <code>bye</code>，Rime 给出「再见」、「再会」两个候选短语。</p>
<p>这时敲空格键，就会打出「再见」；那么怎样打出「再会」呢？</p>
<p>大家首先想到的方法，是：打完编码 <code>bye</code>，按 <code>1</code> 选「再见」，按 <code>2</code> 选「再会」。<br>
可是现在按下 <code>2</code> 去，却是上屏「再见」和数字「2」。可见并没有完成数字键选字的处理，而是将数字同其他符号一样做了顶字上屏处理。</p>
<p>增加一部 <code>selector</code>，即可实现以数字键选字。</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="comment"># ...</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;5&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">speller</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">selector</span>         <span class="comment"># 选字、换页</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">navigator</span>        <span class="comment"># 移动插入点</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span></span><br><span class="line">  <span class="comment"># ...</span></span><br></pre></td></tr></table></figure>
<p><code>selector</code> 除了数字键，还响应前次页、上下方向键。因此选择第二候选「再会」，既可以按数字 <code>2</code>，又可以按方向键「↓」将「再会」高亮、再按空格键确认。</p>
<p><code>navigator</code> 处理左右方向键、<code>Home</code>、<code>End</code> 键，实现移动插入点的编辑功能。有两种情况需要用到他：一是发现输入码有误需要定位修改，二是缩小候选词对应的输入码的范围、精准地编辑新词组。</p>
<p>接下来向词典添加一组重码，以检验换页的效果：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">name:</span> <span class="string">hello</span></span><br><span class="line"><span class="attr">version:</span> <span class="string">&quot;2&quot;</span></span><br><span class="line"><span class="attr">sort:</span> <span class="string">original</span></span><br><span class="line"><span class="string">...</span></span><br><span class="line"></span><br><span class="line"><span class="string">大家好</span>	<span class="string">hello</span></span><br><span class="line"><span class="string">再见</span>	<span class="string">bye</span></span><br><span class="line"><span class="string">再会</span>	<span class="string">bye</span></span><br><span class="line"></span><br><span class="line"><span class="string">星期一</span>	<span class="string">monday</span></span><br><span class="line"><span class="string">星期二</span>	<span class="string">tuesday</span></span><br><span class="line"><span class="string">星期三</span>	<span class="string">wednesday</span></span><br><span class="line"><span class="string">星期四</span>	<span class="string">thursday</span></span><br><span class="line"><span class="string">星期五</span>	<span class="string">friday</span></span><br><span class="line"><span class="string">星期六</span>	<span class="string">saturday</span></span><br><span class="line"><span class="string">星期日</span>	<span class="string">sunday</span></span><br><span class="line"></span><br><span class="line"><span class="string">星期一</span>	<span class="string">weekday</span></span><br><span class="line"><span class="string">星期二</span>	<span class="string">weekday</span></span><br><span class="line"><span class="string">星期三</span>	<span class="string">weekday</span></span><br><span class="line"><span class="string">星期四</span>	<span class="string">weekday</span></span><br><span class="line"><span class="string">星期五</span>	<span class="string">weekday</span></span><br><span class="line"><span class="string">星期六</span>	<span class="string">weekday</span></span><br><span class="line"><span class="string">星期日</span>	<span class="string">weekday</span></span><br></pre></td></tr></table></figure>
<p>默认每页候选数为 5，输入 <code>weekday</code>，显示「星期一」至「星期五」。再敲 <code>Page_Down</code> 显示第二页后选词「星期六、星期日」。</p>
<h3 id="输出中文标点">输出中文标点</h3>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="comment"># ...</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;6&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">speller</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punctuator</span>        <span class="comment"># 处理符号按键</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">selector</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">navigator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span></span><br><span class="line">  <span class="attr">segmentors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">abc_segmentor</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_segmentor</span>   <span class="comment"># 划界，与前后方的其他编码区分开</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">fallback_segmentor</span></span><br><span class="line">  <span class="attr">translators:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">echo_translator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_translator</span>  <span class="comment"># 转换</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">table_translator</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># ...</span></span><br><span class="line"></span><br><span class="line"><span class="attr">punctuator:</span>             <span class="comment"># 设置符号表，这里直接导入默认的</span></span><br><span class="line">  <span class="attr">import_preset:</span> <span class="string">default</span></span><br></pre></td></tr></table></figure>
<p>这次的修改，要注意 <code>punctuator</code>, <code>punct_segmentor</code>, <code>punct_translator</code> 相对于其他组件的位置。</p>
<p><code>punctuator/import_preset</code> 告诉 Rime 使用一套默认的符号表。他的值 <code>default</code> 可以换成其他名字如 <code>xxx</code>，则 Rime 会读取 <code>xxx.yaml</code> 里面定义的符号表。</p>
<p>如今再敲 <code>hello.</code> 就会得到「大家好。」</p>
<h3 id="用符号键换页">用符号键换页</h3>
<p>早先流行用 <code>-</code> 和 <code>=</code> 这一对符号换页，如今流行用 <code>,</code> 和 <code>.</code> 。<br>
在第六版中「，」「。」是会顶字上屏的。现在要做些处理以达到一键两用的效果。</p>
<p>Rime 提供了 <code>key_binder</code> 组件，他能够在一定条件下，将指定按键绑定为另一个按键。对于本例就是：</p>
<ul>
<li>当展现候选菜单时，句号键（<code>period</code>）绑定为向后换页（<code>Page_Down</code>）</li>
<li>当已有（向后）换页动作时，逗号键（<code>comma</code>）绑定为向前换页（<code>Page_Up</code>）</li>
</ul>
<p>逗号键向前换页的条件之所以比句号键严格，是为了「，」仍可在未进行换页的情况下顶字上屏。</p>
<p>经过 <code>key_binder</code> 的处理，用来换页的逗号、句号键改头换面为前、后换页键，从而绕过 <code>punctuator</code>，最终被 <code>selector</code> 当作换页来处理。</p>
<p>最终的代码如下：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="attr">schema_id:</span> <span class="string">hello</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">大家好</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;7&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">key_binder</span>  <span class="comment"># 抢在其他 processor 处理之前判定是否换页用的符号键</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">speller</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punctuator</span>  <span class="comment"># 否则「，。」就会由此上屏</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">selector</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">navigator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span></span><br><span class="line">  <span class="attr">segmentors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">abc_segmentor</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_segmentor</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">fallback_segmentor</span></span><br><span class="line">  <span class="attr">translators:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">echo_translator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_translator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">table_translator</span></span><br><span class="line"></span><br><span class="line"><span class="attr">translator:</span></span><br><span class="line">  <span class="attr">dictionary:</span> <span class="string">hello</span></span><br><span class="line"></span><br><span class="line"><span class="attr">punctuator:</span></span><br><span class="line">  <span class="attr">import_preset:</span> <span class="string">default</span></span><br><span class="line"></span><br><span class="line"><span class="attr">key_binder:</span></span><br><span class="line">  <span class="attr">bindings:</span>             <span class="comment"># 每条定义包含条件、接收按键（IBus 规格的键名，可加修饰符，如「Control+Return」）、发送按键</span></span><br><span class="line"></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">when:</span>   <span class="string">paging</span>    <span class="comment"># 仅当已发生向后换页时，</span></span><br><span class="line">      <span class="attr">accept:</span> <span class="string">comma</span>     <span class="comment"># 将「逗号」键……</span></span><br><span class="line">      <span class="attr">send:</span>   <span class="string">Page_Up</span>   <span class="comment"># 关联到「向前换页」；于是 navigator 将收到一发 Page_Up</span></span><br><span class="line"></span><br><span class="line">    <span class="bullet">-</span> <span class="attr">when:</span>   <span class="string">has_menu</span>  <span class="comment"># 只要有候选字即满足条件</span></span><br><span class="line">      <span class="attr">accept:</span> <span class="string">period</span></span><br><span class="line">      <span class="attr">send:</span>   <span class="string">Page_Down</span></span><br></pre></td></tr></table></figure>
<h2 id="【二】修炼之道">【二】修炼之道</h2>
<p>与【大家好】这个方案不同。以下一组示例，主要演示如何活用符号键盘，以及罗马字转写式输入。</p>
<h3 id="改造键盘">改造键盘</h3>
<p>莫以为【大家好】是最最简单的输入法方案。码表式输入法，不如「键盘式」输入法来得简单明快！</p>
<p>用 <code>punctuator</code> 这一套组件，就可实现一款键盘输入法：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Rime schema</span></span><br><span class="line"><span class="comment"># encoding: utf-8</span></span><br><span class="line"></span><br><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="attr">schema_id:</span> <span class="string">numbers</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">数字之道</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;1&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punctuator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span></span><br><span class="line">  <span class="attr">segmentors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_segmentor</span></span><br><span class="line">  <span class="attr">translators:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_translator</span></span><br><span class="line"></span><br><span class="line"><span class="attr">punctuator:</span></span><br><span class="line">  <span class="attr">half_shape:</span> <span class="meta">&amp;symtable</span></span><br><span class="line">    <span class="string">&quot;1&quot;</span> <span class="string">:</span> <span class="string">一</span></span><br><span class="line">    <span class="string">&quot;2&quot;</span> <span class="string">:</span> <span class="string">二</span></span><br><span class="line">    <span class="string">&quot;3&quot;</span> <span class="string">:</span> <span class="string">三</span></span><br><span class="line">    <span class="string">&quot;4&quot;</span> <span class="string">:</span> <span class="string">四</span></span><br><span class="line">    <span class="string">&quot;5&quot;</span> <span class="string">:</span> <span class="string">五</span></span><br><span class="line">    <span class="string">&quot;6&quot;</span> <span class="string">:</span> <span class="string">六</span></span><br><span class="line">    <span class="string">&quot;7&quot;</span> <span class="string">:</span> <span class="string">七</span></span><br><span class="line">    <span class="string">&quot;8&quot;</span> <span class="string">:</span> <span class="string">八</span></span><br><span class="line">    <span class="string">&quot;9&quot;</span> <span class="string">:</span> <span class="string">九</span></span><br><span class="line">    <span class="string">&quot;0&quot;</span> <span class="string">:</span> <span class="string">〇</span></span><br><span class="line">    <span class="string">&quot;s&quot;</span> <span class="string">:</span> <span class="string">十</span></span><br><span class="line">    <span class="string">&quot;b&quot;</span> <span class="string">:</span> <span class="string">百</span></span><br><span class="line">    <span class="string">&quot;q&quot;</span> <span class="string">:</span> <span class="string">千</span></span><br><span class="line">    <span class="string">&quot;w&quot;</span> <span class="string">:</span> <span class="string">万</span></span><br><span class="line">    <span class="string">&quot;n&quot;</span> <span class="string">:</span> <span class="string">年</span></span><br><span class="line">    <span class="string">&quot;y&quot;</span> <span class="string">:</span> [ <span class="string">月</span>, <span class="string">元</span>, <span class="string">亿</span> ]</span><br><span class="line">    <span class="string">&quot;r&quot;</span> <span class="string">:</span> <span class="string">日</span></span><br><span class="line">    <span class="string">&quot;x&quot;</span> <span class="string">:</span> <span class="string">星期</span></span><br><span class="line">    <span class="string">&quot;j&quot;</span> <span class="string">:</span> <span class="string">角</span></span><br><span class="line">    <span class="string">&quot;f&quot;</span> <span class="string">:</span> <span class="string">分</span></span><br><span class="line">    <span class="string">&quot;z&quot;</span> <span class="string">:</span> [ <span class="string">之</span>, <span class="string">整</span> ]</span><br><span class="line">    <span class="string">&quot;d&quot;</span> <span class="string">:</span> <span class="string">第</span></span><br><span class="line">    <span class="string">&quot;h&quot;</span> <span class="string">:</span> <span class="string">号</span></span><br><span class="line">    <span class="string">&quot;.&quot;</span> <span class="string">:</span> <span class="string">点</span></span><br><span class="line">  <span class="attr">full_shape:</span> <span class="meta">*symtable</span></span><br></pre></td></tr></table></figure>
<p>对，所谓「键盘输入法」，就是按键和字直接对应的输入方式。</p>
<p>这次，不再写 <code>punctuator/import_preset</code> 这项，而是自订了一套符号表。</p>
<p>鸹！原来 <code>punctuator</code> 不单可以用来打出标点符号；还可以重定义空格以及全部 94 个可打印 ASCII 字符（码位 0x20 至 0x7e）。</p>
<p>在符号表代码里，用对应的 ASCII 字符表示按键。记得这些按键字符要放在引号里面，YAML 才能够正确解析喔。</p>
<p>示例代码表演了两种符号的映射方式：一对一及一对多。一对多者，按键后符号不会立即上屏，而是……嘿嘿，自己体验吧 <code>:-)</code></p>
<p>关于代码里 <code>symtable</code> 的一点解释：</p>
<p>这是 YAML 的一种语法，<code>&amp;symtable</code> 叫做「锚点标签」，给紧随其后的内容起个名字叫 <code>symtable</code>；<br>
<code>*symtable</code> 则相当于引用了 <code>symtable</code> 所标记的那段内容，从而避免重复。</p>
<p>Rime 里的符号有「全角」、「半角」两种状态。本方案里暂不作区分，教 <code>half_shape</code>、<code>full_shape</code> 使用同一份符号表。</p>
<h3 id="大写数字键盘">大写数字键盘</h3>
<p>灵机一动，不如利用「全、半角」模式来区分「大、小写」中文数字！</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="comment"># ...</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;2&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">switches:</span></span><br><span class="line">  <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">full_shape</span></span><br><span class="line">    <span class="attr">states:</span> [ <span class="string">小写</span>, <span class="string">大写</span> ]</span><br><span class="line"></span><br><span class="line"><span class="comment"># ...</span></span><br></pre></td></tr></table></figure>
<p>先来定义状态开关：<code>0</code> 态改「半角」为「小写」，<code>1</code> 态改「全角」为「大写」。</p>
<p>这样一改，再打开「方案选单」，方案「数字之道」底下就会多出个「小写→大写」的选项，每选定一次、状态随之反转一次。</p>
<p>接着给 <code>half_shape</code>、<code>full_shape</code> 定义不同的符号表：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">punctuator:</span></span><br><span class="line">  <span class="attr">half_shape:</span></span><br><span class="line">    <span class="string">&quot;1&quot;</span> <span class="string">:</span> <span class="string">一</span></span><br><span class="line">    <span class="string">&quot;2&quot;</span> <span class="string">:</span> <span class="string">二</span></span><br><span class="line">    <span class="string">&quot;3&quot;</span> <span class="string">:</span> <span class="string">三</span></span><br><span class="line">    <span class="string">&quot;4&quot;</span> <span class="string">:</span> <span class="string">四</span></span><br><span class="line">    <span class="string">&quot;5&quot;</span> <span class="string">:</span> <span class="string">五</span></span><br><span class="line">    <span class="string">&quot;6&quot;</span> <span class="string">:</span> <span class="string">六</span></span><br><span class="line">    <span class="string">&quot;7&quot;</span> <span class="string">:</span> <span class="string">七</span></span><br><span class="line">    <span class="string">&quot;8&quot;</span> <span class="string">:</span> <span class="string">八</span></span><br><span class="line">    <span class="string">&quot;9&quot;</span> <span class="string">:</span> <span class="string">九</span></span><br><span class="line">    <span class="string">&quot;0&quot;</span> <span class="string">:</span> <span class="string">〇</span></span><br><span class="line">    <span class="string">&quot;s&quot;</span> <span class="string">:</span> <span class="string">十</span></span><br><span class="line">    <span class="string">&quot;b&quot;</span> <span class="string">:</span> <span class="string">百</span></span><br><span class="line">    <span class="string">&quot;q&quot;</span> <span class="string">:</span> <span class="string">千</span></span><br><span class="line">    <span class="string">&quot;w&quot;</span> <span class="string">:</span> <span class="string">万</span></span><br><span class="line">    <span class="string">&quot;n&quot;</span> <span class="string">:</span> <span class="string">年</span></span><br><span class="line">    <span class="string">&quot;y&quot;</span> <span class="string">:</span> [ <span class="string">月</span>, <span class="string">元</span>, <span class="string">亿</span> ]</span><br><span class="line">    <span class="string">&quot;r&quot;</span> <span class="string">:</span> <span class="string">日</span></span><br><span class="line">    <span class="string">&quot;x&quot;</span> <span class="string">:</span> <span class="string">星期</span></span><br><span class="line">    <span class="string">&quot;j&quot;</span> <span class="string">:</span> <span class="string">角</span></span><br><span class="line">    <span class="string">&quot;f&quot;</span> <span class="string">:</span> <span class="string">分</span></span><br><span class="line">    <span class="string">&quot;z&quot;</span> <span class="string">:</span> [ <span class="string">之</span>, <span class="string">整</span> ]</span><br><span class="line">    <span class="string">&quot;d&quot;</span> <span class="string">:</span> <span class="string">第</span></span><br><span class="line">    <span class="string">&quot;h&quot;</span> <span class="string">:</span> <span class="string">号</span></span><br><span class="line">    <span class="string">&quot;.&quot;</span> <span class="string">:</span> <span class="string">点</span></span><br><span class="line">  <span class="attr">full_shape:</span></span><br><span class="line">    <span class="string">&quot;1&quot;</span> <span class="string">:</span> <span class="string">壹</span></span><br><span class="line">    <span class="string">&quot;2&quot;</span> <span class="string">:</span> <span class="string">贰</span></span><br><span class="line">    <span class="string">&quot;3&quot;</span> <span class="string">:</span> <span class="string">参</span></span><br><span class="line">    <span class="string">&quot;4&quot;</span> <span class="string">:</span> <span class="string">肆</span></span><br><span class="line">    <span class="string">&quot;5&quot;</span> <span class="string">:</span> <span class="string">伍</span></span><br><span class="line">    <span class="string">&quot;6&quot;</span> <span class="string">:</span> <span class="string">陆</span></span><br><span class="line">    <span class="string">&quot;7&quot;</span> <span class="string">:</span> <span class="string">柒</span></span><br><span class="line">    <span class="string">&quot;8&quot;</span> <span class="string">:</span> <span class="string">捌</span></span><br><span class="line">    <span class="string">&quot;9&quot;</span> <span class="string">:</span> <span class="string">玖</span></span><br><span class="line">    <span class="string">&quot;0&quot;</span> <span class="string">:</span> <span class="string">零</span></span><br><span class="line">    <span class="string">&quot;s&quot;</span> <span class="string">:</span> <span class="string">拾</span></span><br><span class="line">    <span class="string">&quot;b&quot;</span> <span class="string">:</span> <span class="string">佰</span></span><br><span class="line">    <span class="string">&quot;q&quot;</span> <span class="string">:</span> <span class="string">千</span></span><br><span class="line">    <span class="string">&quot;w&quot;</span> <span class="string">:</span> <span class="string">万</span></span><br><span class="line">    <span class="string">&quot;n&quot;</span> <span class="string">:</span> <span class="string">年</span></span><br><span class="line">    <span class="string">&quot;y&quot;</span> <span class="string">:</span> [ <span class="string">月</span>, <span class="string">圆</span>, <span class="string">亿</span> ]</span><br><span class="line">    <span class="string">&quot;r&quot;</span> <span class="string">:</span> <span class="string">日</span></span><br><span class="line">    <span class="string">&quot;x&quot;</span> <span class="string">:</span> <span class="string">星期</span></span><br><span class="line">    <span class="string">&quot;j&quot;</span> <span class="string">:</span> <span class="string">角</span></span><br><span class="line">    <span class="string">&quot;f&quot;</span> <span class="string">:</span> <span class="string">分</span></span><br><span class="line">    <span class="string">&quot;z&quot;</span> <span class="string">:</span> [ <span class="string">之</span>, <span class="string">整</span> ]</span><br><span class="line">    <span class="string">&quot;d&quot;</span> <span class="string">:</span> <span class="string">第</span></span><br><span class="line">    <span class="string">&quot;h&quot;</span> <span class="string">:</span> <span class="string">号</span></span><br><span class="line">    <span class="string">&quot;.&quot;</span> <span class="string">:</span> <span class="string">点</span></span><br></pre></td></tr></table></figure>
<p>哈，调出选单切换一下大小写，输出的字全变样！酷。</p>
<p>但是要去选单切换，总不如按下 <code>Shift</code> 就全都有了：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">punctuator:</span></span><br><span class="line">  <span class="attr">half_shape:</span></span><br><span class="line">    <span class="comment"># ... 添加以下这些</span></span><br><span class="line">    <span class="string">&quot;!&quot;</span> <span class="string">:</span> <span class="string">壹</span></span><br><span class="line">    <span class="string">&quot;@&quot;</span> <span class="string">:</span> <span class="string">贰</span></span><br><span class="line">    <span class="string">&quot;#&quot;</span> <span class="string">:</span> <span class="string">参</span></span><br><span class="line">    <span class="string">&quot;$&quot;</span> <span class="string">:</span> [ <span class="string">肆</span>, <span class="string">￥</span>, <span class="string">&quot;$&quot;</span>, <span class="string">&quot;€&quot;</span>, <span class="string">&quot;£&quot;</span> ]</span><br><span class="line">    <span class="string">&quot;%&quot;</span> <span class="string">:</span> [ <span class="string">伍</span>, <span class="string">百分之</span> ]</span><br><span class="line">    <span class="string">&quot;^&quot;</span> <span class="string">:</span> <span class="string">陆</span></span><br><span class="line">    <span class="string">&quot;&amp;&quot;</span> <span class="string">:</span> <span class="string">柒</span></span><br><span class="line">    <span class="string">&quot;*&quot;</span> <span class="string">:</span> <span class="string">捌</span></span><br><span class="line">    <span class="string">&quot;(&quot;</span> <span class="string">:</span> <span class="string">玖</span></span><br><span class="line">    <span class="string">&quot;)&quot;</span> <span class="string">:</span> <span class="string">零</span></span><br><span class="line">    <span class="string">&quot;S&quot;</span> <span class="string">:</span> <span class="string">拾</span></span><br><span class="line">    <span class="string">&quot;B&quot;</span> <span class="string">:</span> <span class="string">佰</span></span><br><span class="line">    <span class="string">&quot;Q&quot;</span> <span class="string">:</span> <span class="string">千</span></span><br><span class="line">    <span class="string">&quot;Y&quot;</span> <span class="string">:</span> <span class="string">圆</span></span><br></pre></td></tr></table></figure>
<p>于是在「小写」态，只要按 <code>Shift</code> + 数字键即可打出大写数字。</p>
<p>用了几下，发现一处小小的不满意：敲 <code>$</code> 这个键，可选的符号有五个之多。想要打出殴元、英镑符号只得多敲几下 <code>$</code> 键使想要的符号高亮；但是按上、下方向键并没有效果，按符号前面标示的数字序号，更是不仅上屏了错误的符号、还多上屏一个数字——</p>
<p>这反映出两个问题。一是 <code>selector</code> 组件缺席使得选字、移动选字光标的动作未得到响应。立即加上：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># ...</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punctuator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">selector</span>        <span class="comment"># 加在这里</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span></span><br><span class="line">  <span class="comment"># ...</span></span><br></pre></td></tr></table></figure>
<p>因为要让 <code>punctuator</code> 来转换数字键，所以 <code>selector</code> 得放在他后头。</p>
<p>好。二一个问题还在：无法用数字序号选字。为解决这个冲突，改用闲置的字母键来选字：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># ...</span></span><br><span class="line"></span><br><span class="line"><span class="attr">menu:</span></span><br><span class="line">  <span class="attr">alternative_select_keys:</span> <span class="string">&quot;acegi&quot;</span></span><br></pre></td></tr></table></figure>
<p>完工。</p>
<h3 id="罗马字之道">罗马字之道</h3>
<p>毕竟，键盘上只有 47 个字符按键、94 个编码字符，对付百十个字还管使。可要输入上千个常用汉字，嫌键盘式输入的编码空间太小，必得采用多字符编码。</p>
<p>罗马字，以拉丁字母的特定排列作为汉语音节的转写形式。一个音节代表一组同音字，再由音节拼写组合成词、句。</p>
<p>凡此单字（音节）编码自然连用而生词、句的输入法，皆可用 <code>script_translator</code> 组件完成基于音节码切分的智能词句转换。他有个别名 <code>r10n_translator</code>——<code>r10n</code> 为 <code>romanization</code> 的简写。但不限于「拼音」、「注音」、「双拼」、「粤拼」等一族基于语音编码的输入法：形式相似者，如「速成」，虽以字形为本，亦可应用。</p>
<p>现在来把【数字之道】改成拼音→中文数字的变换。</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="attr">schema_id:</span> <span class="string">numbers</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">数字之道</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;3&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">speller</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punctuator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">selector</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span></span><br><span class="line">  <span class="attr">segmentors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">abc_segmentor</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_segmentor</span></span><br><span class="line">  <span class="attr">translators:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_translator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">script_translator</span></span><br><span class="line"></span><br><span class="line"><span class="attr">translator:</span></span><br><span class="line">  <span class="attr">dictionary:</span> <span class="string">numbers</span></span><br><span class="line"></span><br><span class="line"><span class="attr">punctuator:</span></span><br><span class="line">  <span class="attr">half_shape:</span> <span class="meta">&amp;symtable</span></span><br><span class="line">    <span class="string">&quot;!&quot;</span> <span class="string">:</span> <span class="string">壹</span></span><br><span class="line">    <span class="string">&quot;@&quot;</span> <span class="string">:</span> <span class="string">贰</span></span><br><span class="line">    <span class="string">&quot;#&quot;</span> <span class="string">:</span> <span class="string">参</span></span><br><span class="line">    <span class="string">&quot;$&quot;</span> <span class="string">:</span> [ <span class="string">肆</span>, <span class="string">￥</span>, <span class="string">&quot;$&quot;</span>, <span class="string">&quot;€&quot;</span>, <span class="string">&quot;£&quot;</span> ]</span><br><span class="line">    <span class="string">&quot;%&quot;</span> <span class="string">:</span> [ <span class="string">伍</span>, <span class="string">百分之</span> ]</span><br><span class="line">    <span class="string">&quot;^&quot;</span> <span class="string">:</span> <span class="string">陆</span></span><br><span class="line">    <span class="string">&quot;&amp;&quot;</span> <span class="string">:</span> <span class="string">柒</span></span><br><span class="line">    <span class="string">&quot;*&quot;</span> <span class="string">:</span> <span class="string">捌</span></span><br><span class="line">    <span class="string">&quot;(&quot;</span> <span class="string">:</span> <span class="string">玖</span></span><br><span class="line">    <span class="string">&quot;)&quot;</span> <span class="string">:</span> <span class="string">零</span></span><br><span class="line">    <span class="string">&quot;S&quot;</span> <span class="string">:</span> <span class="string">拾</span></span><br><span class="line">    <span class="string">&quot;B&quot;</span> <span class="string">:</span> <span class="string">佰</span></span><br><span class="line">    <span class="string">&quot;Q&quot;</span> <span class="string">:</span> <span class="string">千</span></span><br><span class="line">    <span class="string">&quot;W&quot;</span> <span class="string">:</span> <span class="string">万</span></span><br><span class="line">    <span class="string">&quot;N&quot;</span> <span class="string">:</span> <span class="string">年</span></span><br><span class="line">    <span class="string">&quot;Y&quot;</span> <span class="string">:</span> [ <span class="string">月</span>, <span class="string">圆</span>, <span class="string">亿</span> ]</span><br><span class="line">    <span class="string">&quot;R&quot;</span> <span class="string">:</span> <span class="string">日</span></span><br><span class="line">    <span class="string">&quot;X&quot;</span> <span class="string">:</span> <span class="string">星期</span></span><br><span class="line">    <span class="string">&quot;J&quot;</span> <span class="string">:</span> <span class="string">角</span></span><br><span class="line">    <span class="string">&quot;F&quot;</span> <span class="string">:</span> <span class="string">分</span></span><br><span class="line">    <span class="string">&quot;Z&quot;</span> <span class="string">:</span> [ <span class="string">之</span>, <span class="string">整</span> ]</span><br><span class="line">    <span class="string">&quot;D&quot;</span> <span class="string">:</span> <span class="string">第</span></span><br><span class="line">    <span class="string">&quot;H&quot;</span> <span class="string">:</span> <span class="string">号</span></span><br><span class="line">    <span class="string">&quot;.&quot;</span> <span class="string">:</span> <span class="string">点</span></span><br><span class="line">  <span class="attr">full_shape:</span> <span class="meta">*symtable</span></span><br></pre></td></tr></table></figure>
<p>符号表里，把小写字母、数字键都空出来了。小写字母用来拼音，数字键用来选重。重点是本次用了 <code>script_translator</code> 这组件。与 <code>table_translator</code> 相似，该组件与 <code>translator/dictionary</code> 指名的词典相关联。</p>
<p>编制词典：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Rime dictionary</span></span><br><span class="line"><span class="comment"># encoding: utf-8</span></span><br><span class="line"></span><br><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">name:</span> <span class="string">numbers</span></span><br><span class="line"><span class="attr">version:</span> <span class="string">&quot;1&quot;</span></span><br><span class="line"><span class="attr">sort:</span> <span class="string">by_weight</span></span><br><span class="line"><span class="attr">use_preset_vocabulary:</span> <span class="literal">true</span></span><br><span class="line"><span class="string">...</span></span><br><span class="line"></span><br><span class="line"><span class="string">一</span>	<span class="string">yi</span></span><br><span class="line"><span class="string">二</span>	<span class="string">er</span></span><br><span class="line"><span class="string">三</span>	<span class="string">san</span></span><br><span class="line"><span class="string">四</span>	<span class="string">si</span></span><br><span class="line"><span class="string">五</span>	<span class="string">wu</span></span><br><span class="line"><span class="string">六</span>	<span class="string">liu</span></span><br><span class="line"><span class="string">七</span>	<span class="string">qi</span></span><br><span class="line"><span class="string">八</span>	<span class="string">ba</span></span><br><span class="line"><span class="string">九</span>	<span class="string">jiu</span></span><br><span class="line"><span class="string">〇</span>	<span class="string">ling</span></span><br><span class="line"><span class="string">零</span>	<span class="string">ling</span></span><br><span class="line"><span class="string">十</span>	<span class="string">shi</span></span><br><span class="line"><span class="string">百</span>	<span class="string">bai</span></span><br><span class="line"><span class="string">千</span>	<span class="string">qian</span></span><br><span class="line"><span class="string">万</span>	<span class="string">wan</span></span><br><span class="line"><span class="string">亿</span>	<span class="string">yi</span></span><br><span class="line"><span class="string">年</span>	<span class="string">nian</span></span><br><span class="line"><span class="string">月</span>	<span class="string">yue</span></span><br><span class="line"><span class="string">日</span>	<span class="string">ri</span></span><br><span class="line"><span class="string">星</span>	<span class="string">xing</span></span><br><span class="line"><span class="string">期</span>	<span class="string">qi</span></span><br><span class="line"><span class="string">时</span>	<span class="string">shi</span></span><br><span class="line"><span class="string">分</span>	<span class="string">fen</span></span><br><span class="line"><span class="string">秒</span>	<span class="string">miao</span></span><br><span class="line"><span class="string">元</span>	<span class="string">yuan</span></span><br><span class="line"><span class="string">角</span>	<span class="string">jiao</span></span><br><span class="line"><span class="string">之</span>	<span class="string">zhi</span></span><br><span class="line"><span class="string">整</span>	<span class="string">zheng</span></span><br><span class="line"><span class="string">第</span>	<span class="string">di</span></span><br><span class="line"><span class="string">号</span>	<span class="string">hao</span></span><br><span class="line"><span class="string">点</span>	<span class="string">dian</span></span><br><span class="line"><span class="string">是</span>	<span class="string">shi</span></span><br></pre></td></tr></table></figure>
<p>※注意： <strong>不要</strong> 从网页复制以上代码到实际的词典文件！因为网页里制表符被转换成空格从而不符合 Rime 词典要求的格式。一些文本编辑器也会将使用者输入的制表符自动转换为空格，请注意检查和设置。</p>
<p>码表里给出了一个「示例」规格的小字集。其中包含几组重码字。</p>
<p>要诀 <code>sort: by_weight</code> 意图是不以码表的顺序排列重码字，而是比较字频。那字频呢？没写出来。</p>
<p>要诀 <code>use_preset_vocabulary: true</code> 用在输入法方案需要支持输入词组、而码表中词组相对匮乏时。编译输入法方案期间引入 Rime 默认的【八股文】词汇——及词频资料！这就是码表中未具字频的原因。</p>
<p>使用【八股文】，要注意码表所用的字形是否与该词汇表一致。八股文的词汇及词频统计都遵照 opencc 繁体字形标准。</p>
<p>如果缺少单字的编码定义，自然也无法导入某些词汇。所以本方案只会导入这个数字「小字集」上的词汇。</p>
<h3 id="用拼写运算定义简码">用拼写运算定义简码</h3>
<p>如今有了一款专门输入数字的拼音输入法。比一比昇阳拼音、朙月拼音和地球拼音，还有哪里不一样？</p>
<p>很快我发现敲 <code>xingqiwu</code> 或 <code>xingqiw</code> 都可得到来自【八股文】的词组「星期五」，这很好。可是敲 <code>xqw</code> 怎会不中呢？</p>
<p>原来 <code>script_translator</code> 罗马字中译的方法是，将输入码序列切分为音节表中的拼写形式，再按音节查词典。不信你找本词典瞧瞧，是不是按完整的拼音（注音）编排的。Rime 词典也一样。并没有 <code>xqw</code> 这样的检索码。</p>
<p>现在我要用 Rime 独门绝活「拼写运算」来定义一种「音序查字法」。令 <code>x</code> 作 <code>xing</code> 的简码，<code>q</code> 作数字之道所有音节中起首为 <code>q</code> 者的简码，即略代音节 <code>qi</code> 与 <code>qian</code>。</p>
<p>「汉语拼音」里还有三个双字母的声符，<code>zh, ch, sh</code> 也可做简码。</p>
<p>添加拼写运算规则：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br></pre></td><td class="code"><pre><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="comment"># ...</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;4&quot;</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#...</span></span><br><span class="line"></span><br><span class="line"><span class="attr">speller:</span></span><br><span class="line">  <span class="attr">algebra:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">&#x27;abbrev/^([a-z]).+$/$1/&#x27;</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">&#x27;abbrev/^([zcs]h).+$/$1/&#x27;</span></span><br></pre></td></tr></table></figure>
<p>如此 Rime 便知，除了码表里那些拼音，还有若干简码也是行得通的拼写形式。再输入 <code>xqw</code>，Rime 将他拆开 <code>x'q'w</code>，再默默对应到音节码 <code>xing'qi'wan</code>、<code>xing'qi'wu</code>、<code>xing'qian'wan</code> 等等，一翻词典就得到了一个好词「星期五」，而其他的组合都说不通。</p>
<p>现在有无有悟到，罗马字转写式输入法与码表式输入法理念上的不同？</p>
<p>哈，做中了。试试看 <code>sss,sss,sssss,sssss</code></p>
<p>却好像不是我要的「四是四，十是十，十四是十四，四十是四十」……</p>
<p>好办。如果某些词汇在方案里很重要，【八股文】又未收录，那么，请添加至码表：</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">---</span></span><br><span class="line"><span class="attr">name:</span> <span class="string">numbers</span></span><br><span class="line"><span class="attr">version:</span> <span class="string">&quot;2&quot;</span></span><br><span class="line"><span class="attr">sort:</span> <span class="string">by_weight</span></span><br><span class="line"><span class="attr">use_preset_vocabulary:</span> <span class="literal">true</span></span><br><span class="line"><span class="string">...</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># ...</span></span><br><span class="line"></span><br><span class="line"><span class="string">四是四</span></span><br><span class="line"><span class="string">十是十</span></span><br><span class="line"><span class="string">十四是十四</span></span><br><span class="line"><span class="string">四十是四十</span></span><br></pre></td></tr></table></figure>
<p>善哉。演示完毕。当然休想就此把 Rime 全盘掌握了。一本《指南书》，若能让读者入门，我止说「善哉〜」</p>
<p>再往后，就只有多读代码，才能见识到各种新颖、有趣的玩法。</p>
<h2 id="【三】最高武艺">【三】最高武艺</h2>
<p>〔警告〕最后这部戏，对智力、技术功底的要求不一般。如果读不下去，不要怪我、不要怀疑自己的智商！</p>
<p>即使跳过本节书也无妨，只是不可忽略了下文《关于调试》这一节！（重要哇……）</p>
<p>请检查是否：</p>
<ul>
<li>※ 已将前两组实例分析透彻</li>
<li>※ 学习完了《拼写运算》</li>
<li>※ 知道双拼是神码</li>
<li>※ 预习 Rime 默认输入法方案之【朙月拼音】</li>
</ul>
<p>设计一款【智能 ABC 双拼】输入法方案做练习！</p>
<figure class="highlight yaml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># Rime schema</span></span><br><span class="line"><span class="comment"># encoding: utf-8</span></span><br><span class="line"></span><br><span class="line"><span class="attr">schema:</span></span><br><span class="line">  <span class="attr">schema_id:</span> <span class="string">double_pinyin_abc</span>  <span class="comment"># 专有的方案标识</span></span><br><span class="line">  <span class="attr">name:</span> <span class="string">智能</span> <span class="string">ABC</span> <span class="string">双拼</span></span><br><span class="line">  <span class="attr">version:</span> <span class="string">&quot;0.9&quot;</span></span><br><span class="line">  <span class="attr">author:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">佛振</span> <span class="string">&lt;chen.sst@gmail.com&gt;</span></span><br><span class="line">  <span class="attr">description:</span> <span class="string">|</span></span><br><span class="line"><span class="string">    朙月拼音，兼容智能 ABC 双拼方案。</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="attr">switches:</span></span><br><span class="line">  <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">ascii_mode</span></span><br><span class="line">    <span class="attr">reset:</span> <span class="number">0</span></span><br><span class="line">    <span class="attr">states:</span> [ <span class="string">中文</span>, <span class="string">西文</span> ]</span><br><span class="line">  <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">full_shape</span></span><br><span class="line">    <span class="attr">states:</span> [ <span class="string">半角</span>, <span class="string">全角</span> ]</span><br><span class="line">  <span class="bullet">-</span> <span class="attr">name:</span> <span class="string">simplification</span></span><br><span class="line">    <span class="attr">states:</span> [ <span class="string">汉字</span>, <span class="string">汉字</span> ]</span><br><span class="line"></span><br><span class="line"><span class="attr">engine:</span></span><br><span class="line">  <span class="attr">processors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">ascii_composer</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">recognizer</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">key_binder</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">speller</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punctuator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">selector</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">navigator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">express_editor</span></span><br><span class="line">  <span class="attr">segmentors:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">ascii_segmentor</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">matcher</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">abc_segmentor</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_segmentor</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">fallback_segmentor</span></span><br><span class="line">  <span class="attr">translators:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">echo_translator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">punct_translator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">script_translator</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">reverse_lookup_translator</span></span><br><span class="line">  <span class="attr">filters:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">simplifier</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">uniquifier</span></span><br><span class="line"></span><br><span class="line"><span class="attr">speller:</span></span><br><span class="line">  <span class="attr">alphabet:</span> <span class="string">zyxwvutsrqponmlkjihgfedcba</span>  <span class="comment"># 呃，倒背字母表完全是个人喜好</span></span><br><span class="line">  <span class="attr">delimiter:</span> <span class="string">&quot; &#x27;&quot;</span>  <span class="comment"># 隔音符号用「&#x27;」；第一位的空白用来自动插入到音节边界处</span></span><br><span class="line">  <span class="attr">algebra:</span>  <span class="comment"># 拼写运算规则，这个才是实现双拼方案的重点。写法有很多种，当然也可以把四百多个音节码一条一条地列举</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">erase/^xx$/</span>             <span class="comment"># 码表中有几个拼音不明的字，编码成 xx 了，消灭他</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">derive/^([jqxy])u$/$1v/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/^zh/A/</span>            <span class="comment"># 替换声母键，用大写以防与原有的字母混淆</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/^ch/E/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/^sh/V/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/^([aoe].*)$/O$1/</span>  <span class="comment"># 添上固定的零声母 o，先标记为大写 O</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/ei$/Q/</span>            <span class="comment"># 替换韵母键</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/ian$/W/</span>           <span class="comment"># ※2</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/er$|iu$/R/</span>        <span class="comment"># 对应两种韵母的；音节 er 现在变为 OR 了</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/[iu]ang$/T/</span>       <span class="comment"># ※1</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/ing$/Y/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/uo$/O/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/uan$/P/</span>           <span class="comment"># ※3</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/i?ong$/S/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/[iu]a$/D/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/en$/F/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/eng$/G/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/ang$/H/</span>           <span class="comment"># 检查一下在此之前是否已转换过了带介音的 ang；好，※1 处有了</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/an$/J/</span>            <span class="comment"># 如果※2、※3 还无有出现在上文中，应该把他们提到本行之前</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/iao$/Z/</span>           <span class="comment"># 对——像这样让 iao 提前出场</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/ao$/K/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/in$|uai$/C/</span>       <span class="comment"># 让 uai 提前出场</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/ai$/L/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/ie$/X/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/ou$/B/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/un$/N/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/[uv]e$|ui$/M/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xlit/QWERTYOPASDFGHJKLZXCVBNM/qwertyopasdfghjklzxcvbnm/</span>  <span class="comment"># 最后把双拼码全部变小写</span></span><br><span class="line"></span><br><span class="line"><span class="attr">translator:</span></span><br><span class="line">  <span class="attr">dictionary:</span> <span class="string">luna_pinyin</span>     <span class="comment"># 与【朙月拼音】共用词典</span></span><br><span class="line">  <span class="attr">prism:</span> <span class="string">double_pinyin_abc</span>    <span class="comment"># prism 要以本输入法方案的名称来命名，以免把朙月拼音的拼写映射表覆盖掉</span></span><br><span class="line">  <span class="attr">preedit_format:</span>             <span class="comment"># 这段代码用来将输入的双拼码反转为全拼显示；待见双拼码的可以把这段拿掉</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/o(\w)/0$1/</span>        <span class="comment"># 零声母先改为 0，以方便后面的转换</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)q/$1ei/</span>       <span class="comment"># 双拼第二码转换为韵母</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)n/$1un/</span>       <span class="comment"># 提前转换双拼码 n 和 g，因为转换后的拼音里就快要出现这两个字母了，那时将难以分辨出双拼码</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)g/$1eng/</span>      <span class="comment"># 当然也可以采取事先将双拼码变为大写的办法来与转换过的拼音做区分，可谁让我是高手呢</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)w/$1ian/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([dtnljqx])r/$1iu/</span>  <span class="comment"># 对应多种韵母的双拼码，按搭配的声母做区分（最好别用排除式如 r 容易出状况）</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/0r/0er/</span>             <span class="comment"># 另一种情况，注意先不消除 0，以防后面把 e 当作声母转换为 ch</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([nljqx])t/$1iang/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)t/$1uang/</span>       <span class="comment"># 上一行已经把对应到 iang 的双拼码 t 消灭，于是这里不用再列举相配的声母</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)y/$1ing/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([dtnlgkhaevrzcs])o/$1uo/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)p/$1uan/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([jqx])s/$1iong/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)s/$1ong/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([gkhaevrzcs])d/$1ua/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)d/$1ia/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)f/$1en/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)h/$1ang/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)j/$1an/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)k/$1ao/</span>       <span class="comment"># 默默检查：双拼码 o 已经转换过了</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)l/$1ai/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)z/$1iao/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)x/$1ie/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)b/$1ou/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([nl])m/$1ve/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([jqxy])m/$1ue/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/(\w)m/$1ui/</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">&quot;xform/(^|[ &#x27;])a/$1zh/&quot;</span>  <span class="comment"># 复原声母，音节开始处的双拼字母 a 改写为 zh；其他位置的才真正是 a</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">&quot;xform/(^|[ &#x27;])e/$1ch/&quot;</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">&quot;xform/(^|[ &#x27;])v/$1sh/&quot;</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/0(\w)/$1/</span>          <span class="comment"># 好了，现在可以把零声母拿掉啦</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([nljqxy])v/$1ü/</span>   <span class="comment"># 这样才是汉语拼音 :-)</span></span><br><span class="line"></span><br><span class="line"><span class="attr">reverse_lookup:</span></span><br><span class="line">  <span class="attr">dictionary:</span> <span class="string">cangjie5</span></span><br><span class="line">  <span class="attr">prefix:</span> <span class="string">&quot;`&quot;</span></span><br><span class="line">  <span class="attr">tips:</span> <span class="string">〔仓颉〕</span></span><br><span class="line">  <span class="attr">preedit_format:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">&quot;xlit|abcdefghijklmnopqrstuvwxyz|日月金木水火土竹戈十大中一弓人心手口尸廿山女田难卜符|&quot;</span></span><br><span class="line">  <span class="attr">comment_format:</span></span><br><span class="line">    <span class="bullet">-</span> <span class="string">xform/([nl])v/$1ü/</span></span><br><span class="line"></span><br><span class="line"><span class="attr">punctuator:</span></span><br><span class="line">  <span class="attr">import_preset:</span> <span class="string">default</span></span><br><span class="line"></span><br><span class="line"><span class="attr">key_binder:</span></span><br><span class="line">  <span class="attr">import_preset:</span> <span class="string">default</span></span><br><span class="line"></span><br><span class="line"><span class="attr">recognizer:</span></span><br><span class="line">  <span class="attr">import_preset:</span> <span class="string">default</span></span><br><span class="line">  <span class="attr">patterns:</span></span><br><span class="line">    <span class="attr">reverse_lookup:</span> <span class="string">&quot;`[a-z]*$&quot;</span></span><br></pre></td></tr></table></figure>
<p>完毕。</p>
<p>这是一道大题。通过改造拼写法而创作出新的输入法方案。</p>
<h2 id="【四】标准库">【四】标准库</h2>
<p>如果需要制作完全属于自己的输入法方案，少不了要了解 Rime 的标准库。此时，请客倌品读<a target="_blank" rel="noopener" href="https://github.com/LEOYoon-Tsaw/Rime_collections/blob/master/Rime_description.md">《Rime 方案制作详解》</a>。更多新意，就在你的笔下！</p>
<h2 id="关于调试">关于调试</h2>
<p>如此复杂的输入法方案，很可能需要反覆调试方可达到想要的结果。</p>
<p>请于试验时及时查看日志中是否包含错误信息。日志文件位于：</p>
<ul>
<li>【中州韵】 <code>/tmp/rime.ibus.*</code></li>
<li>【小狼毫】 <code>%TEMP%\rime.weasel.*</code></li>
<li>【鼠鬚管】 <code>$TMPDIR/rime.squirrel.*</code></li>
<li>各发行版的早期版本 <code>用户资料夹/rime.log</code></li>
</ul>
<p>按照日志的级别分为 INFO / 信息、WARNING / 警告、ERROR / 错误。<br>
后两类应重点关注，如果新方案部署后不可用或输出与设计不一致，原因可能在此。</p>
<p>没有任何错误信息，就是不好使，有可能是码表本身的问题，比如把码表中文字和编码两列弄颠倒了——Rime 等你输入由汉字组成的编码，然而键盘没有可能做到这一点（否则也不再需要输入法了）。</p>
<p>后续有计划为输入法方案创作者开发名为<a target="_blank" rel="noopener" href="http://rime.github.io/blog/2013/08/28/spelling-algebra-debugger/">「拼写运算调试器」</a>的工具，能够较直观地看到每一步拼写运算的结果。有助于定义双拼这样大量使用拼写运算的方案。</p>
<h1>东风破</h1>
<p>「东风破早梅，向暖一枝开。」</p>
<p>构想在 Rime 输入软件完善后，能够连结汉字字形、音韵、输入法爱好者的共同兴趣，形成稳定的使用者社羣，搭建一个分享知识的平台。</p>
<p><a target="_blank" rel="noopener" href="https://github.com/rime/plum">【东风破】</a>，定义为配置管理器及 Rime 输入法方案仓库，是广大 Rime 用家分享配置和输入法方案的平台。</p>
<p>Rime 是一款强调个性的输入法。</p>
<p>Rime 不要定义输入法应当是哪个样、而要定义输入法可以玩出哪些花样。</p>
<p>Rime 不可能通过默认更多的输入法方案来满足玩家的需求；真正的玩家一定有一般人想不到的高招。</p>
<p>未来一定会有，<a target="_blank" rel="noopener" href="https://github.com/rime/plum">【东风破】</a>（注：现已投入运行），让用家轻松地找到最新、最酷、最适合自己的 Rime 输入法方案。</p>
<!-- 用 Vim 命令在相邻中西文字符之间添加一个空隔：
:%sm/[㐀-﨩]\zs\ze[a-zA-Z0-9`%]\|[a-zA-Z0-9`%]\zs\ze[㐀-﨩]/ /g
若需要手动确认每处修改，请在末尾添加参数 c。
--></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="http://xishansnow.github.io">西山晴雪</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="http://xishansnow.github.io/posts/6811304.html">http://xishansnow.github.io/posts/6811304.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="http://xishansnow.github.io" target="_blank">西山晴雪的知识笔记</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/%E8%BD%AF%E4%BB%B6%E5%AE%89%E8%A3%85%E4%B8%8E%E4%BD%BF%E7%94%A8/">软件安装与使用</a><a class="post-meta__tags" href="/tags/Linux/">Linux</a></div><div class="post_share"><div class="social-share" data-image="/img/book_01.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/sharejs/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/posts/41ac964d.html"><img class="prev-cover" src="/img/coffe_02.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">RIME输入法方案配置手册</div></div></a></div><div class="next-post pull-right"><a href="/posts/9a60fb94.html"><img class="next-cover" src="/img/010.png" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">音乐文件 Cue 切割方法</div></div></a></div></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><div><a href="/posts/f7905162.html" title="Linux 环境配置文件处理流程"><img class="cover" src="/img/009.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-03-10</div><div class="title">Linux 环境配置文件处理流程</div></div></a></div><div><a href="/posts/41ac964d.html" title="RIME输入法方案配置手册"><img class="cover" src="/img/coffe_02.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-04-02</div><div class="title">RIME输入法方案配置手册</div></div></a></div><div><a href="/posts/7ea2da9d.html" title="Youyun"><img class="cover" src="/img/book_12.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-04-01</div><div class="title">Youyun</div></div></a></div><div><a href="/posts/9a60fb94.html" title="音乐文件 Cue 切割方法"><img class="cover" src="/img/010.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-04-02</div><div class="title">音乐文件 Cue 切割方法</div></div></a></div><div><a href="/posts/d3f42a0f.html" title="nmcli网络配置命令"><img class="cover" src="/img/book_09.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-08-18</div><div class="title">nmcli网络配置命令</div></div></a></div><div><a href="/posts/5c4624dd.html" title="pyton、node.js、hexo配置指南"><img class="cover" src="/img/009.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2022-12-13</div><div class="title">pyton、node.js、hexo配置指南</div></div></a></div></div></div></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E5%86%99%E5%9C%A8%E5%89%8D%E9%9D%A2"><span class="toc-text">1 写在前面</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%80%82%E5%90%88%E4%BA%BA%E7%BE%A4"><span class="toc-text">适合人群</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%9F%BA%E6%9C%AC%E6%A6%82%E5%BF%B5"><span class="toc-text">基本概念</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E4%B8%BA%E4%BB%80%E4%B9%88%E8%A6%81%E8%BF%99%E4%B9%88%E7%B9%81%E7%90%90%EF%BC%9F"><span class="toc-text">为什么要这么繁琐？</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E5%87%86%E5%A4%87%E5%BC%80%E5%B7%A5"><span class="toc-text">2 准备开工</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-Rime-%E7%9A%84%E4%B8%BB%E8%A6%81%E5%8F%91%E8%A1%8C%E7%89%88"><span class="toc-text">2.1 Rime 的主要发行版</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2-Rime-%E9%87%87%E7%94%A8%E6%96%87%E6%9C%AC%E6%96%87%E4%BB%B6%E5%81%9A%E5%AE%9A%E5%88%B6"><span class="toc-text">2.2 Rime 采用文本文件做定制</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-%E6%96%87%E6%9C%AC%E6%96%87%E4%BB%B6%E7%9A%84%E6%A0%BC%E5%BC%8F"><span class="toc-text">2.3 文本文件的格式</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-4-Rime-%E7%9A%84%E6%96%87%E4%BB%B6%E5%88%86%E5%B8%83%E5%8F%8A%E4%BD%9C%E7%94%A8"><span class="toc-text">2.4 Rime 的文件分布及作用</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#3-%E8%AF%A6%E8%A7%A3%E8%BE%93%E5%85%A5%E6%B3%95%E6%96%B9%E6%A1%88"><span class="toc-text">3 详解输入法方案</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#3-1-%E6%96%B9%E6%A1%88%E6%8F%8F%E8%BF%B0"><span class="toc-text">3.1 方案描述</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-2-%E8%BE%93%E5%85%A5%E6%B3%95%E5%BC%95%E6%93%8E%E4%B8%8E%E5%8A%9F%E8%83%BD%E7%BB%84%E4%BB%B6"><span class="toc-text">3.2 输入法引擎与功能组件</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-1-Processors-%E5%8A%9F%E8%83%BD%E7%BB%84%E4%BB%B6"><span class="toc-text">3.2.1 Processors 功能组件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-2-Segmentors-%E5%8A%9F%E8%83%BD%E7%BB%84%E4%BB%B6"><span class="toc-text">3.2.2 Segmentors 功能组件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-3-Translators-%E5%8A%9F%E8%83%BD%E7%BB%84%E4%BB%B6"><span class="toc-text">3.2.3 Translators 功能组件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-2-4-Filters-%E5%8A%9F%E8%83%BD%E7%BB%84%E4%BB%B6"><span class="toc-text">3.2.4 Filters 功能组件</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-3-%E8%AF%8D%E5%85%B8%E6%96%87%E4%BB%B6%E4%B8%8E%E7%A0%81%E8%A1%A8"><span class="toc-text">3.3 词典文件与码表</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#3-3-1-%E8%AF%8D%E5%85%B8%E6%96%87%E4%BB%B6"><span class="toc-text">3.3.1 词典文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-3-2-%E7%A0%81%E8%A1%A8"><span class="toc-text">3.3.2 码表</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-4-%E8%AE%BE%E7%BD%AE%E9%A1%B9%E9%80%9F%E6%9F%A5%E6%89%8B%E5%86%8C"><span class="toc-text">3.4 设置项速查手册</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-5-%E5%85%AB%E8%82%A1%E6%96%87"><span class="toc-text">3.5 八股文</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-6-%E7%BC%96%E8%AF%91%E8%BE%93%E5%85%A5%E6%B3%95%E6%96%B9%E6%A1%88"><span class="toc-text">3.6 编译输入法方案</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#3-7-%E5%B8%83%E7%BD%B2-Rime"><span class="toc-text">3.7 布署 Rime</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#4-%E5%AE%9A%E5%88%B6%E6%8C%87%E5%8D%97"><span class="toc-text">4 定制指南</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link"><span class="toc-text">拼写运算</span></a></li><li class="toc-item toc-level-1"><a class="toc-link"><span class="toc-text">综合演练</span></a><ol class="toc-child"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E3%80%90%E4%B8%80%E3%80%91%E7%A0%B4%E7%A9%BA%E4%B8%AD%E5%87%BA%E9%9E%98"><span class="toc-text">【一】破空中出鞘</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#Hello-Rime"><span class="toc-text">Hello, Rime!</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%BC%80%E5%A7%8B%E6%94%B9%E8%A3%85"><span class="toc-text">开始改装</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%9B%E5%BB%BA%E5%80%99%E9%80%89%E9%A1%B9"><span class="toc-text">创建候选项</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BC%96%E5%86%99%E8%AF%8D%E5%85%B8"><span class="toc-text">编写词典</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%AE%9E%E7%8E%B0%E9%80%89%E5%AD%97%E5%8F%8A%E6%8D%A2%E9%A1%B5"><span class="toc-text">实现选字及换页</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%BE%93%E5%87%BA%E4%B8%AD%E6%96%87%E6%A0%87%E7%82%B9"><span class="toc-text">输出中文标点</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%94%A8%E7%AC%A6%E5%8F%B7%E9%94%AE%E6%8D%A2%E9%A1%B5"><span class="toc-text">用符号键换页</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E3%80%90%E4%BA%8C%E3%80%91%E4%BF%AE%E7%82%BC%E4%B9%8B%E9%81%93"><span class="toc-text">【二】修炼之道</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%94%B9%E9%80%A0%E9%94%AE%E7%9B%98"><span class="toc-text">改造键盘</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%A4%A7%E5%86%99%E6%95%B0%E5%AD%97%E9%94%AE%E7%9B%98"><span class="toc-text">大写数字键盘</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%BD%97%E9%A9%AC%E5%AD%97%E4%B9%8B%E9%81%93"><span class="toc-text">罗马字之道</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E7%94%A8%E6%8B%BC%E5%86%99%E8%BF%90%E7%AE%97%E5%AE%9A%E4%B9%89%E7%AE%80%E7%A0%81"><span class="toc-text">用拼写运算定义简码</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E3%80%90%E4%B8%89%E3%80%91%E6%9C%80%E9%AB%98%E6%AD%A6%E8%89%BA"><span class="toc-text">【三】最高武艺</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E3%80%90%E5%9B%9B%E3%80%91%E6%A0%87%E5%87%86%E5%BA%93"><span class="toc-text">【四】标准库</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%85%B3%E4%BA%8E%E8%B0%83%E8%AF%95"><span class="toc-text">关于调试</span></a></li></ol></li><li class="toc-item toc-level-1"><a class="toc-link"><span class="toc-text">东风破</span></a></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By 西山晴雪</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="translateLink" type="button" title="简繁转换">繁</button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="algolia-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="search-wrap"><div id="algolia-search-input"></div><hr/><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-info"><div class="algolia-stats"></div><div class="algolia-poweredBy"></div></div></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="/js/tw_cn.js"></script><script src="https://cdn.jsdelivr.net/npm/@fancyapps/ui/dist/fancybox.umd.min.js"></script><script>function panguFn () {
  if (typeof pangu === 'object') pangu.autoSpacingPage()
  else {
    getScript('https://cdn.jsdelivr.net/npm/pangu/dist/browser/pangu.min.js')
      .then(() => {
        pangu.autoSpacingPage()
      })
  }
}

function panguInit () {
  if (true){
    GLOBAL_CONFIG_SITE.isPost && panguFn()
  } else {
    panguFn()
  }
}

document.addEventListener('DOMContentLoaded', panguInit)</script><script src="https://cdn.jsdelivr.net/npm/algoliasearch/dist/algoliasearch-lite.umd.min.js"></script><script src="https://cdn.jsdelivr.net/npm/instantsearch.js/dist/instantsearch.production.min.js"></script><script src="/js/search/algolia.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/katex/dist/katex.min.css"><script src="https://cdn.jsdelivr.net/npm/katex/dist/contrib/copy-tex.min.js"></script><script>(() => {
  document.querySelectorAll('#article-container span.katex-display').forEach(item => {
    btf.wrap(item, 'div', { class: 'katex-wrap'})
  })
})()</script><script>(() => {
  const $mermaidWrap = document.querySelectorAll('#article-container .mermaid-wrap')
  if ($mermaidWrap.length) {
    window.runMermaid = () => {
      window.loadMermaid = true
      const theme = document.documentElement.getAttribute('data-theme') === 'dark' ? '' : ''

      Array.from($mermaidWrap).forEach((item, index) => {
        const mermaidSrc = item.firstElementChild
        const mermaidThemeConfig = '%%{init:{ \'theme\':\'' + theme + '\'}}%%\n'
        const mermaidID = 'mermaid-' + index
        const mermaidDefinition = mermaidThemeConfig + mermaidSrc.textContent
        mermaid.mermaidAPI.render(mermaidID, mermaidDefinition, (svgCode) => {
          mermaidSrc.insertAdjacentHTML('afterend', svgCode)
        })
      })
    }

    const loadMermaid = () => {
      window.loadMermaid ? runMermaid() : getScript('https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js').then(runMermaid)
    }

    window.pjax ? loadMermaid() : document.addEventListener('DOMContentLoaded', loadMermaid)
  }
})()</script></div><script id="canvas_nest" defer="defer" color="0,0,255" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/canvas-nest.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc/metingjs/dist/Meting.min.js"></script></div></body></html>